Monday, May 13, 2024
 Popular · Latest · Hot · Upcoming
140
rated 0 times [  147] [ 7]  / answers: 1 / hits: 15588  / 11 Years ago, wed, october 16, 2013, 12:00:00

I'm going to create simple social networking site.
so... I want to know that how Facebook store comments for posts.



is Facebook store Posts and its comments in same database table row,
then how they store a long list of comments in a one table row field.
or is it have each database table for each post, so that can make the comments for that post in that table row.



What is the best database structure for a simple social network site like CMS.
but it could be handle a large amount of users.



Please help me in this matter.
Thanks.


More From » php

 Answers
17

Small example of what you could do:



Table users:



users
--------
id
name


Table comments:



comments
--------
id
comment_text
posted_by
posted_to
date_posted


When user with ID 342 posts a comment to user 783's profile, you can store the comment like so:



INSERT INTO comments(comment_text, posted_by, posted_to, date_posted) 
VALUES ('Hi!', 342, 783, '2013-10-16 11:17:00');


Then, when you're selecting comments to show on a user's profile, simply join the posted_by and posted_to columns up with the relevant ids in the users table.


[#74953] Tuesday, October 15, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dustin

Total Points: 599
Total Questions: 105
Total Answers: 106

Location: Belarus
Member since Tue, Mar 14, 2023
1 Year ago
dustin questions
;