Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

mysql

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....

like image 872
KPO Avatar asked Jan 20 '23 17:01

KPO


2 Answers

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.

like image 170
Shakti Singh Avatar answered Jan 22 '23 07:01

Shakti Singh


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.

like image 28
James Avatar answered Jan 22 '23 06:01

James