一个简单的SQL Select查询来抓取社交图中所有连接的人? [英] A simple SQL Select query to crawl all connected people in a social graph?

查看:98
本文介绍了一个简单的SQL Select查询来抓取社交图中所有连接的人?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是最短或最快的SQL选择查询或SQL过程来抓取社交图。想象一下,我们有这张表:

  UId FriendId 
1 2
2 1
2 4
1 3
5 7
7 5
7 8
5 9
9 7

我们在这里有两个子集,我说的是一个sql查询或过程,如果我们通过:



Uid = 4用 uid:{1,2,3}



返回结果集行或如果
Uid = 9,则返回结果集行,其中包含 uid:{5,7,8}



对不起,我的英文不好。

有人,包括n级的朋友?我不认为没有递归是不可能的。



你如何做到这一点在这里解释:
https://inviqa.com/blog/graphs-database-sql-meets-social-network


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   7
7   5
7   8
5   9
9   7

We have two subset of people here, i'm talking about a sql query or procedure which if we pass:

Uid = 4 return the result set rows with uid : {1, 2, 3}

or if

Uid = 9 return the result set rows with uid : {5, 7, 8}

Sorry for my poor english.

解决方案

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

这篇关于一个简单的SQL Select查询来抓取社交图中所有连接的人?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆