简体   繁体   中英

insert reference in comment table that joins two sessions (blog and news)

I am finalizing a comments system and was with a doubt.

I have a table for blogs and one for news, and they accept comments.

My comments table receives the text and the id. I wonder if I need to (or should I) go through some sort of reference to know where the comment comes from.

table comment

id | id_content | text | ref
1  | 1          | test | blog
2  | 1          | test | news

thanks

depending on the number of comments you expect to receive there are two ways of doing this ...

1 - parent_tbl, parent_id - in one big comment table

2 - two tables for comments with a parent_id - one for each primary table

either way you need to index properly, the second will always work faster, but it doesn't expand well if you say add "press_releases" now you have to duplicate code, tables, what not.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM