Reputation: 2135
I am working on a social/community site and I am confused about how to store posts and comments.
If I store post with an post_id, post_creator, time, post/text, privacy in a table post14 then how would I store comments(+commentator) of this post?
Notice I may have 10,000 users each average posts 10 mean 1 million post_id.
Is this good idea to create a table for each post_id and store comments? Or is there a better alternative?
Upvotes: 0
Views: 664
Reputation: 1
After 10 years, another approach that warrants consideration is to explore MongoDB, a NoSQL databse, where we uses collections instad of tables and document instead of rows.
Upvotes: -1
Reputation: 3691
You have to create 3 tables
Users
Posts
Comments
So in Post, you will have a column user_id which will be coming from table Users. In your comments you will have post_id which will be related to table Post. This way its all fully manageable and if you have 10000 users nothing to worry I guess...
Upvotes: 0
Reputation: 56
it' horrible to create a table for each post. you can create 3 tables as user, posts, and comments and link them by foreign key constrain.
Upvotes: 2