views:

89

answers:

1

Hey guys I find it hard to believe that Facebook uses simple sql, surely it would use some other method but lets assume for now it does use sql how would the code assimilating the 'wall' work?

Lets say that there is three tables (just for the example)

Friends: id (entry key) - uid(your id) - fid (your mates' id)

Wall:id (entry key) - username - comment - time - commentcount

comments: id (entry key) - wid (wall id (original comment)) - reply - time

Lets forget about the like part and report etc, as well as mod things (ip, ban etc.) How would this work?

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

That's your own wall but how do they get friend's? A heap of unions?

+1  A: 

Hi,

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

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

Arild R