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"