Quantcast
Channel: Facebook database design? - Stack Overflow
Viewing all articles
Browse latest Browse all 12

Answer by deep9c for Facebook database design?

$
0
0

Probably there is a table, which stores the friend <-> user relation, say "frnd_list", having fields 'user_id','frnd_id'.

Whenever a user adds another user as a friend, two new rows are created.

For instance, suppose my id is 'deep9c' and I add a user having id 'akash3b' as my friend, then two new rows are created in table "frnd_list" with values ('deep9c','akash3b') and ('akash3b','deep9c').

Now when showing the friends-list to a particular user, a simple sql would do that: "select frnd_id from frnd_list where user_id="where is the id of the logged-in user (stored as a session-attribute).


Viewing all articles
Browse latest Browse all 12

Trending Articles





<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>