![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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, please let me know. Thanks! |
#3
| |||
| |||
|
|
On Jul 31, 2:37 pm, "John Ruan" <rds1... (AT) sh163 (DOT) net> wrote: 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, please let me know. Thanks! People pid key name varchar Pair pair_id key pid1 key pid2 key Distance pair_id key distance int i think this is a fairly good structure. I have a Pair table so that you can have key1234 jane jim key1234 jim jane as two rows, in case space isn't a consideration i hope that this makes sense! I could see the pair table getting huge tho. It'd be nice if the pair_id could somehow be a hash that you compute given pid1 and pid2 that is the same whether pid1 is the first key or pid2 is the first key. |
#4
| |||
| |||
|
|
If anybody has any idea on how to do this, or any references, please let me know. |
#5
| |||
| |||
|
|
If anybody has any idea on how to do this, or any references, please let me know. Get a copy of the White Paper I did for Cogito on this topic (www.cogitoinc.com). They make a product for searching networks. I wrote SQL for the "Kevin Bacon" problem to compare them against SQL; they won by orders of magnitude. The fundamental problem is a Cartesian explosion in SQL that examines all possible paths. |
#6
| |||
| |||
|
|
Celko, Would you show me the sample DDL and DML (SELECT statement) or the direct link to see them? |
#7
| |||
| |||
|
|
Celko, Would you show me the sample DDL and DML (SELECT statement) or the direct link to see them? They hold the copyrights, but I can ask them to do something. I will cut and paste this thread and forward it. |
#8
| |||
| |||
|
|
I am trying to design a database model related to the small world (or six degree of separation) phenomenon. |
#9
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |