views:

71

answers:

2

In social networking site, a person has friends/followers. There is a chain of relation. How would be data stored at database in this scenario? This is a very huge information, still result of a query comes back very fast on these sites.

Is it possible that someone explain the relations between various entities? What does make the search result so much fast?

What type of algorithm is implemented?If possible give me example.

+2  A: 

This would seem like a MANY-TO-MANY Situation.

Something like, where UserRelations.UserID and UserRelations.UserRelatedID should be foreign keys to Users

Users
 - UserID
 - UserName

UserRelations
 -UserID
 -UserRelatedID
 -RelationshipType
astander
+2  A: 

Facebook developed a custom NoSQL database for their inbox search, which has since been open-sourced. http://en.wikipedia.org/wiki/Apache_Cassandra.

There are some interesting topics related to your question on facebook's engineering page - http://www.facebook.com/Engineering.

Brendan Abel