How to implement the Facebook friends module in the database?

I am developing a facebook type application for my institute.

and I'm stuck in the friends module. That is, how to find out if individual users are just friends.

I walked a lot, but did not get satisfactory answers. What I get will be: there will be many friends of the person, and the introduction of users and their friends in a separate table will only increase the redundancy and large size of the database.

I was thinking about using a graph with vertices as users and edges as a join.

But how to implement something like this in db.

Or How does Facebook handle so many relationships?

+3
source share
3 answers

this link can help you create an RDBMS using the friends modules. http://techportal.inviqa.com/2009/09/07/graphs-in-the-database-sql-meets-social-networks/

+2
source

Personally, I would have a highlighted table:

You may have a table with two columns: userID and friendID

Since the relationship between users in db will be many-to-many, normalization requires a link table that breaks it into many-on-one-on-many

http://dev.mysql.com/tech-resources/articles/intro-to-normalization.html#03

+1
source

. , , . Neo4j , dowload. , - .

+1

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


All Articles