t**********s 发帖数: 930 | 1 I am trying to design a database model related to the small world (or six
degree of separation) phenomenon.
With this design, I should be able to write two queries efficiently:
a) How many degrees of separation are there between two people.
(assuming they are connected). You may assume that you do not have to check
for more than 6 degrees.
b) Who are all the people that have x degrees of separation from a
given person.
If anybody has any idea on how to do this, or any references, pleas | t*****g 发帖数: 1275 | 2 If the only concern is the efficiency of these two queries, just create a
table as simple as
id1, id2, degree
where id1 and id2 are the user ids and degree is from 1 to 6
Well, insert/update/delete would be disastrous, but that's not what you are
concerned, right? (assume this is an academic project)
check
me
【在 t**********s 的大作中提到】 : I am trying to design a database model related to the small world (or six : degree of separation) phenomenon. : With this design, I should be able to write two queries efficiently: : a) How many degrees of separation are there between two people. : (assuming they are connected). You may assume that you do not have to check : for more than 6 degrees. : b) Who are all the people that have x degrees of separation from a : given person. : If anybody has any idea on how to do this, or any references, pleas
| t**********s 发帖数: 930 | 3 Well, I am supposed to create a series of tables to hold a person and all
their friends.
Besides, how can I write the two queries to:
a) How many degrees of separation are there between two people. (
assuming they are connected). You may assume that you do not have to check
for more than 6 degrees.
b) Who are all the people that have x degrees of separation from a
given person.
are
【在 t*****g 的大作中提到】 : If the only concern is the efficiency of these two queries, just create a : table as simple as : id1, id2, degree : where id1 and id2 are the user ids and degree is from 1 to 6 : Well, insert/update/delete would be disastrous, but that's not what you are : concerned, right? (assume this is an academic project) : : check : me
|
|