문제

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?

도움이 되었습니까?

해결책

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.

다른 팁

You have to create 3 tables

  1. Users
  2. Posts
  3. 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...

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top