Networks are the most general form of data structures. Networks include
lists, hierarchies, tables, graphs, etc. The data in the following
example forms a type of network that is managed systematically by true
network databases but is impossible to manage systematical in RM/RMDBs
(note that one requirement for being systematic in RM/RMDBs means
complying with the Information Principle).
Suppose Adam has children named John(male), Mary(female), Bob(male) and
Francis(bisexual). And John likes Mary and Francis, but hates Bob.
Genders male/female are opposites. Feelings like/hate are opposites.
Based on the above, we want to find the following, without referring to
John's parent (Adam) or John's gender (male) directly:
1) John's siblings.
2) John's brothers.
3) John's sisters.
4) John's sibling of opposite gender.
Also we want to find:
1) with whom is John's relationship opposite that with Mary.
2) With whom is John's relationship opposite that with Bob.
3) Whom does John not have a feeling for.
Below dbd script implements the above example.
(new 'male 'gender)
(new 'female 'gender)
(new 'bisexual 'gender)
(new 'opposite)
(set male opposite female)
(set female opposite male)
(new 'adam 'person)
(new 'john 'person)
(set john gender male)
(new 'mary 'person)
(set mary gender female)
(new 'bob 'person)
(set bob gender male)
(new 'francis 'person)
(set francis gender bisexual)
(set adam child john)
(set adam child mary)
(set adam child bob)
(set adam child francis)
(new 'like 'feeling)
(new 'hate 'feeling)
(set like opposite hate)
(set hate opposite like)
(set john like mary)
(set john like francis)
(set john hate bob)
(; Get john's siblings
by getting persons
and are children of john's parent
and are not himself)
(; Gets mary, bob and francis)
(!= (and (get person instance *)
(get (get * child john) child *))
john)
(; Get john's brothers
by getting persons
whose gender is male
and are children of john's parent
and are not himself)
(; Gets bob)
(!= (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 are children of john's parent
and are not himself)
(; Gets mary)
(!= (and (get person instance *)
(get * gender female)
(get (get * child john) child *))
john)
(; Get john's sibling of opposite gender
by getting persons
whose gender is opposite of john's gender
and are children of john's parent)
(; Gets mary)
(and (get person instance *)
(get * gender (get (get john gender *) opposite *))
(get (get * child john) child *))
(; Get persons with whom
john's relationship is opposite that with mary)
(; Gets bob)
(get john (get (get john * mary) opposite *) *)
(; Get persons with whom
john's relationship is opposite that with bob)
(; Gets mary and francis)
(get john (get (get john * bob) opposite *) *)
(; Get persons for whom john has no feeling)
(; Gets adam)
(!= (and (get person instance *)
(not (get john (get feeling instance *) *)))
john)
>> Stay informed about: Finding Brothers & Sisters (with dbd)