Quick view facebook db?

Hey guys, it’s hard for me to believe that Facebook uses simple sql, of course, it will use some other method, but suppose now it uses sql, how would the code assimilating the work of the “wall”?

Suppose there are three tables (for example only)

Friends: id (enter key) - uid (your id) - fid (identifier of your friends)

Wall: id (enter key) - username - comment - time - comment

comments: id (enter key) - wid (wall identifier (original comment)) - response - time

Let's forget about the similar part and message, etc., as well as the mod (ip, ban, etc.). How it works?

Select wall.id, wall.username, wall.comment, wall.time, wall.commentcount, comments.wid, comments.reply, comments.time FROM wall internal join comments ON wall.id = comments.wid ORDER BY wall.time ;

What is your own wall, but how do they get a friend? A bunch of unions?

+4
source share
2 answers

here you can find more information on how Facebook (and MANY other BIG sites) works.

http://highscalability.com/blog/category/facebook

+1
source

Well, as the founder of a social networking site, let me explain something. You are close to the right one ... Regarding your question about how they get friends, in mysql situation, they will at the same time iterate over all their friends, where their identifier matches the friends table. Then they will quote WHERE comments, each of the friends ID matches the user ID in my case, aka $ _SESSION ['user_id'] = uid. Remember, however, that comments are not only on the while loop, but also on the while loop, so that it not only requests one instance of the registered user user = uid.

0
source

Source: https://habr.com/ru/post/1309078/


All Articles