How will the data be stored in the database in the case of a social networking site?

A person has friends / followers on a social network. There is a chain of relationships. How will the data be stored in the database in this scenario? This is a lot of information, yet the result of the query is returned to these sites very quickly.

Is it possible for someone to explain the relationship between different entities? What makes the search result so fast?

What type of algorithm is implemented? Give me an example if possible.

+2


source to share


2 answers


It would seem like MANY MANY situations.

Something like where UserRelations.UserID

u UserRelations.UserRelatedID

should be foreign keys forUsers



Users
 - UserID
 - UserName

UserRelations
 -UserID
 -UserRelatedID
 -RelationshipType

      

+4


source


Facebook developed a custom NoSQL database for search in Inbox, which has since been open. http://en.wikipedia.org/wiki/Apache_Cassandra .



There are some interesting topics related to your question on the facebook tech support page - http://www.facebook.com/Engineering .

+3


source







All Articles