If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Searching on friends, friends' friends, friends' friends' friends, ...

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-10-03, 15:10
Vernon Vernon is offline
Registered User
 
Join Date: Jul 2003
Posts: 24
Searching on friends, friends' friends, friends' friends' friends, ...

Hi,

I am facing a challenge problem (at least for me). I need to serach anyone in a personal network whom hobby is golf. A personal network is someone's friends, and his/her friends' friends, and his/her friends' friends' friends, and so on. This problem can be broken down into

1.how to represent the graphs data type in RD
2. how to search recursively

Thanks for any input

v.
Reply With Quote
  #2 (permalink)  
Old 12-11-03, 17:22
joebednarz joebednarz is offline
Registered User
 
Join Date: Dec 2003
Location: Oklahoma, USA
Posts: 354
Sounds like a hierarchical query problem. Look here for some help:

http://download-west.oracle.com/docs...4a.htm#2053937

JoeB
Reply With Quote
  #3 (permalink)  
Old 12-26-03, 18:35
Vernon Vernon is offline
Registered User
 
Join Date: Jul 2003
Posts: 24
Quote:
Originally posted by joebednarz
Sounds like a hierarchical query problem. Look here for some help:

http://download-west.oracle.com/docs...4a.htm#2053937

JoeB
Thanks for the inforamtion. I don't have the access to Oracle site. From my studying, DB only can represents the type of relationship in an limited manner.
Reply With Quote
  #4 (permalink)  
Old 12-26-03, 18:52
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
if you do not have access to the oracle site, you should get it

it's free

you should really know how oracle hierarchical queries work


a comment about your search requirement

if you store friends, and friends of friends, etc., but all you want is anyone who plays golf, why not just search the table?

presumably people wouldn't even be in the table if they weren't somebody's friend



rudy
http://r937.com/
Reply With Quote
  #5 (permalink)  
Old 12-26-03, 19:21
Vernon Vernon is offline
Registered User
 
Join Date: Jul 2003
Posts: 24
I came out a solution that only store the relationship between two people if it exists. And the application will take care of join them together.

I don't use Oracle at this moment for this project . The hierarchical query doesn't seem to be standard one.
Reply With Quote
  #6 (permalink)  
Old 12-26-03, 19:38
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
true, the START WITH / CONNECT BY syntax is proprietary, only oracle supports it

however, no other database (to my knowledge) supports recursion

if you can restrict how many "levels" deep the relationships can go, you can obtain what you want with a multiple self-join using left outer joins

see http://www.sitepointforums.com/showt...ted#post975494

rudy
Reply With Quote
  #7 (permalink)  
Old 12-26-03, 20:21
Vernon Vernon is offline
Registered User
 
Join Date: Jul 2003
Posts: 24
Quote:
Originally posted by r937
true, the START WITH / CONNECT BY syntax is proprietary, only oracle supports it

however, no other database (to my knowledge) supports recursion

if you can restrict how many "levels" deep the relationships can go, you can obtain what you want with a multiple self-join using left outer joins

see http://www.sitepointforums.com/showt...ted#post975494

rudy
I had been the point before. The situation is the recursion depth can't be restrict. It is no way I can go down the path.
Reply With Quote
  #8 (permalink)  
Old 12-26-03, 20:44
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
well, in that case, you will have to (shock! horror!) run a query inside a loop!!

all i can say is, good luck to you, sir


rudy
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On