Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Databases General > Single query to...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 10 Topic 3173 of 3295
Post > Topic >>

Single query to find multi-level relation****ps?

by John Gordon <gordon@[EMAIL PROTECTED] > May 28, 2008 at 05:05 PM

I'm writing some code to su****t a contact database, where a contact
can be either a person or a group.  Groups can contain people directly
and can also contain other groups.

The (simplified) table structure looks like this:

PERSON
------
person_id  number   primary key

GROUP
-----
group_id   number   primary key

MEMBER_OF_GROUP
---------------
person_id  number   primary key 1 (foreign key -> PERSON.person_id)
group_id   number   primary key 2 (foreign key -> GROUP.group_id)

GROUP_IN_GROUP
--------------
subgroup_id    number  primary key 1 (foreign key -> GROUP.group_id)
supergroup_id  number  primary key 2 (foreign key -> GROUP.group_id)

I want to write a single query that will tell me if a person is a member
of a given group, whether as a direct member via the MEMBER_OF_GROUP
table or as an indirect member of a child group via the GROUP_IN_GROUP
table.

Anyone have suggestions?

-- 
John Gordon                   A is for Amy, who fell down the stairs
gordon@[EMAIL PROTECTED]
              B is for Basil, assaulted by bears
                                -- Edward Gorey, "The Gashlycrumb Tinies"
 




 10 Posts in Topic:
Single query to find multi-level relationships?
John Gordon <gordon@[E  2008-05-28 17:05:05 
Re: Single query to find multi-level relationships?
"David Cressey"  2008-05-29 10:05:50 
Re: Single query to find multi-level relationships?
John Gordon <gordon@[E  2008-06-02 18:20:46 
Re: Single query to find multi-level relationships?
--CELKO-- <jcelko212@[  2008-06-03 04:55:53 
Re: Single query to find multi-level relationships?
Lennart <Erik.Lennart.  2008-06-03 05:28:15 
Re: Single query to find multi-level relationships?
John Gordon <gordon@[E  2008-06-03 14:51:53 
Re: Single query to find multi-level relationships?
Ed Prochak <edprochak@  2008-06-03 05:58:37 
Re: Single query to find multi-level relationships?
John Gordon <gordon@[E  2008-06-03 14:50:12 
Re: Single query to find multi-level relationships?
--CELKO-- <jcelko212@[  2008-06-03 07:57:39 
Re: Single query to find multi-level relationships?
--CELKO-- <jcelko212@[  2008-05-29 04:57:35 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Dec 5 9:52:37 CST 2008.