Reputation: 880
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 insert 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....
Upvotes: 4
Views: 1569
Reputation: 2307
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.
Upvotes: 1
Reputation: 218
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.
Upvotes: 1
Reputation: 17530
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
Upvotes: -1
Reputation: 86476
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.
Upvotes: 8