A simple SQL Select query to crawl all connected people in a social graph?

后端 未结 3 1957
逝去的感伤
逝去的感伤 2021-01-03 09:56

What is the shortest or fastest SQL select query or SQL procedure to crawl a social graph. Imagine we have this table:

UId FriendId
1   2
2   1
2   4
1   3
5         


        
3条回答
  •  自闭症患者
    2021-01-03 10:43

    So you want get all friends of someone, including n-th degree friends? I don't think it is possible without recursion.

    How you can do that is explained here: https://inviqa.com/blog/graphs-database-sql-meets-social-network

提交回复
热议问题