Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2005-01-06 : 08:36:30
|
| liste writes "My problem resembles relationships within a community. I have a table of community members (lets say tblMembers: memberID (numeric), memberName (varchar)). I have an other table that holds the relationships of members within the community (lets say tblRelationship: memberID, friendID both numeric)I'd like to do something similar to friendster's display: given 2 members, I'd like to find the relationship between these two members. My desired output is similar to:Given member1 and memberXmember1 -> member2 -> member3 -> member4 -> member5 -> memberXso the query output might be like:member1 member2member2 member3member3 member4member5 memberXI wrote a storedproc that does the job. My trouble is, it does checks by degrees. What I mean is it first checks if there is a 1st degree contact, if not then it checks for 2nd degree, if not 3rd and etc. I did it by queries using the current degree (first 1 join, then 2 joins, then 3 joins and etc) number of joins. It does the job, and finds the shortest path but I think this puts a lot of burden on the server (imagine many members doing queries for the 6th degree members). So I was wondering if there is a more efficient method of querying?Thank you" |
|
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2005-01-06 : 13:55:08
|
Are you finding that your query is slow?Maybe if you posted your query, we might be able to fine tune it, but it doesn't sound like you are far off from a good solution.Corey |
 |
|
|
|
|
|