The network underlying the following example can be managed
systematically by true network databases. It cannot be managed
systematically (ie null-less, normalized, non-redundant, follows
information principle and remains so when extended to meet new data
requirements) in the Relational Model (RM) or the CODYSL Network Model
(a hybrid of the Relational and Hierarchal Data Models).
Suppose Adam(30) has children named John(tall), Mary(short), Bob(fat),
Sue(short/thin), Adam(5). Builds tall/short and fat/thin are opposites.
We want to find the following, without explicitly referring to John's
parent (Adam) or John's build (tall):
1) John's siblings.
2) John's fat siblings.
3) John's siblings of opposite build.
4) Persons with builds with whom Bob's build has same relationship as
John's build's relationship with Mary's build (without explicitly
referring to that relationship in the query).
Below dbd script implements the above example.
(new 'tall 'build)
(new 'athletic 'build)
(new 'petite 'build)
(new 'short 'build)
(new 'thin 'build)
(new 'fat 'build)
(new 'opposite)
(set tall opposite short)
(set short opposite tall)
(set fat opposite thin)
(set thin opposite fat)
(new 'john 'person)
(set john build tall)
(new 'mary 'person)
(set mary build short)
(new 'bob 'person)
(set bob build fat)
(new 'sue 'person)
(set sue build short)
(set sue build thin)
(new 'age)
(new 'adam 'person)
(set+ adam age '10)
(new 'adam 'person)
(set+ (it) age '30)
(set (it) child john)
(set (it) child mary)
(set (it) child bob)
(set (it) child sue)
(set (it) child (and (get * name 'adam)
(get * age 10)))
(; Get john's siblings
by getting persons
who are children of john's parent
and are not himself)
(; Gets mary, bob, sue, little adam)
(!= (and (get person instance *)
(get (get * child john) child *))
john)
(; Get john's fat siblings
by getting persons
whose build is fat
and are children of john's parent
and are not himself)
(; Gets bob)
(!= (and (get person instance *)
(get * build fat)
(get (get * child john) child *))
john)
(; Get john's siblings of opposite build
by getting persons
whose build is opposite of john's build
and are children of john's parent
and are not himself)
(; Gets mary and sue)
(!= (and (get person instance *)
(get * build (get (get john build *) opposite *))
(get (get * child john) child *))
john)
(; Get persons with builds with whom bob's build relationship is
the same as john's build relationship to mary's build)
(; Gets sue)
(get * build (get (get bob build *)
(get (get john build *) * (get mary build *))
*))
>> Stay informed about: Network Example: Siblings of Opposite Build