简体   繁体   中英

What would be the best database structure for this…:

I am struggling finding the best way to understand this:

Let's say I am a developer at Facebook, and I had to redesign Facebook's MySQL databases (focusing only on their "Activities" feature where you can see what your friends shared). What would be the best way to store Status messages , comments on those messages , likes , and other things keeping in mind that users should have access to their friends' posts only. Not everyone else's.

Can anyone suggest any possible way of handling this. Database structure or anything would be much appreciated.

Before I forget: I am actually conducting a research (for my personal growth in webdev). I don't intend to work for Facebook or creating a new Facebook or anything like that. I just want to gain a deeper understanding of how this situation would have been handled. If that's okay with everyone... :-)

This is a fairly subjective question, but I'd set it up something like this:

3 tables:

status_messages

id (PK) | user_id (FK) | message | timestamp

status_comments

id (PK) | status_id (FK) | user_id (FK) | comment | timestamp

status_likes

id (PK) | status_id (FK) | user_id (FK) | timestamp

PK = primary key FK = foreign key

Obviously this wouldn't be the complete solution, but you can get the point from the structure. You'd also need some kind of members/users table, and Facebook obviously does a lot more than just what I have outlined above, but the above would suffice for a very simple implementation of the system.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM