Re: Network Example: Sibling of Opposite Gender

From: Neo <neo55592_at_hotmail.com>
Date: 30 Dec 2006 23:08:50 -0800
Message-ID: <1167548930.651636.269330_at_s34g2000cwa.googlegroups.com>


> --Getting John brothers and sisters with out involving Adam
> select P3.name, P3.sex
> from people P2
> inner join link L2
> on P2.id = L2.parent
> inner join people P3
> on P3.id = L2.child
> inner join (select L1.parent from link L1 inner join people P1
> on L1.child = P1.id where P1.name = 'John') B
> on P2.id = B.parent
> where P3.name <> 'John'

Ok, it checked out in Access also. Below is dbd's equivalent:

(!= (and (get person instance *)

            (get (get * child john) child *))
     john)

> --Getting ANY brother OR sister to any sibling of opposite sex
> select P3.name, P3.sex
> from people P2
> inner join link L2
> on P2.id = L2.parent
> inner join people P3
> on P3.id = L2.child
> inner join (select L1.parent from link L1 inner join people P1
> on L1.child = P1.id where P1.name = 'John') B
> on P2.id = B.parent
> inner join (select P1.sex from link L1 inner join people P1
> on L1.child = P1.id where P1.name = 'John') C
> on P3.sex <> C.sex
> where P3.name <> 'John'

OK, and below is dbd's expression; however, it use explicitly stored relationships, instead of the not equal function, to determine opposite genders.

(!= (and (get person instance *)

            (get * gender (get (get john gender *) opposite *))
            (get (get * child john) child *))
     john)

> Case closed...I have solved the second challenge simply by using an additional join.

You certainly have. If you would like to try another, see 'finding siblings of opposite build' in response to Marshall's post below. Received on Sun Dec 31 2006 - 08:08:50 CET

Original text of this message