Re: Relationship(s) for human family structure

From: Neo <>
Date: Tue, 21 Aug 2007 19:24:26 -0000
Message-ID: <>

> I [john] was married and had a son [bob].
> He [bob] married and had a daughter [sue].
> My wife [mary] died.
> I [john] married my son's [bob] daughter [sue].
> Now I [john] am my own grandfather.
> Try resolving that relationally!

Below dbd script models and resolves above. To verify, copy and paste into dbd's input box and click submit button. Gender neutral relationships (ie parent, spouse) are used. (Note: check parent in view menu beforehand, to display parent relationships. By default relationships that move up hierarchy are disabled)

(new 'male 'gender)
(new 'female 'gender)

(new 'john 'person)
(set john gender male)

(new 'mary 'person)
(set mary gender female)

(new 'bob 'person)
(set bob gender male)

(new 'sue 'person)
(set sue gender female)

(; Note: parent already defined in db)
(new 'spouse 'relationship)

(set john spouse mary)
(set mary spouse john)

(set bob parent john)
(set sue parent bob)

(set john spouse sue)
(set sue spouse john)

(; Get john's grandfather via wife's side of family)
(; Gets john himself!)
(and (get (and (get (get john spouse *) parent *)

                     (get * gender male)) parent *)
       (get * gender male))

Unlike the CODASYL network data model which is infact a hybrid relational/hierarchal data model, dbd represents things with a network of nodes where each node implements the fundamental unit of computation: the AND gate or a switch. A user models a thing by creating a node and relating it to existing nodes in db. Each db is ntialized with nodes for basic things such as symbols and common classes. Besides GUI/API, a user communicates with the db via expressions. The general syntax of an expression is "(func [inp1] [inp2] ...)". Each expression begins with a "(" and ends with corresponding ")". The first element after "(" is the function. The renaming elements, if any, are function inputs. An element of an expression can itself be a subexpression. Expressions starting with "(;" are comments. The expression "(new)" creates a new node in the db. The expression "(it)" refers to the last node created by "(new)". To relate a node, say to a string (sequence of symbols), use the expression "(set (it) name 'john)". Note that a string is indicated by preceeding it with a single quote. Once a node has been named by a string, it can be referenced by its name. See following example:

(; Create a node for a person to be named by the string 'john)

(; Relate new node to its name, the string 'john)
(set (it) name 'john)
(; We can now reference new node by simply by john)

(; Now we want to make john an instance of person)
(; Create new node for person)

(; Relate its name as the string 'person)
(set (it) name 'person)

(; In order to view item in GUI, relate new class to tree root)
(set db item person)

(; Set john is an instance of person)
(set person instance john)

(; The following expression is equivalent to that above)
(; The subexpressions are solved for *,

   prior to executing the main expression)
(set (get * name 'person) instance (get * name 'john))

(; create a person/doctor named mary using shortcut method)
(; Note that the new function's

   input1 is the name of the new node
   and remaining inputs classify it)
(new 'mary 'person 'doctor)

For more details, see Received on Tue Aug 21 2007 - 21:24:26 CEST

Original text of this message