How to find Brothers and Sisters?
From: Neo <neo55592_at_hotmail.com>
Date: 1 Dec 2006 13:01:40 -0800
Message-ID: <1165006900.320669.285480_at_n67g2000cwd.googlegroups.com>
Suppose Adam has children named John(male), Jack(male) and Mary(female). What schema/query finds John's brothers and sisters based only on direct relationships to parent and gender. A direct relationship would be parent/child. An indirect/derived relationship would be brother/sister. The query is not to use Adam directly. Below is a solution using dbd.
(!= (and (get person instance *)
Date: 1 Dec 2006 13:01:40 -0800
Message-ID: <1165006900.320669.285480_at_n67g2000cwd.googlegroups.com>
Suppose Adam has children named John(male), Jack(male) and Mary(female). What schema/query finds John's brothers and sisters based only on direct relationships to parent and gender. A direct relationship would be parent/child. An indirect/derived relationship would be brother/sister. The query is not to use Adam directly. Below is a solution using dbd.
(new 'male 'gender)
(new 'female 'gender)
(new 'adam 'person)
(new 'john 'person)
(set john gender male)
(new 'jack 'person)
(set jack gender male)
(new 'mary 'person)
(set mary gender female)
(new 'child 'verb)
(set adam child john)
(set adam child jack)
(set adam child mary)
(; Get john's brothers
by getting persons
whose gender is male
and is child of john's father
and that person is not himself)
(!= (and (get person instance *)
(get * gender male) (get (get * child john) child *)) john)
(; Get john's sisters
by getting persons
whose gender is female
and is child of john's father
and that person is not himself)
(; Gets mary)
(!= (and (get person instance *)
(get * gender female) (get (get * child john) child *)) john)Received on Fri Dec 01 2006 - 22:01:40 CET