开发者

Is it better to store all comments for everything in one table or have multiple tables?

Lets say you have 3 or 4 site features like photos, videos, wall posts, etc. And each have the ability for you to leave a comment.

Should the DB have 1 table and 开发者_如何学Cinsert all those comments in that one table with their respective unique IDs or should they have like 3 or 4 other tables like Photo_table, video_table, etc....


Better to put them in single table and add respective unique IDs of different features with one extra column type (Because ids from those master tables can be same) which will indicate whether this comment is from Photo,video or anything else.

Suppose if project grow in future have some more features ie (10 features) then you do not have to create tables for all these.


You could implement it in a number of ways. If a comment has the same basic fields in all cases, you would probably have an easier time using one table. If the comments have different data depending on the type of comment, it would be easier to separate them out.


Sourav,

Speed will not be an issue if there an index tag on the "Comment type" field. Less number of tables is good for data maintenance.


It woule be better to use 3 different table photos_comment, wall_comment,... coz it will speed up the look up process when showing comments for photos and will help you to manage the db too

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜