Re: why hierarchy?

From: Neo <neo55592_at_hotmail.com>
Date: 1 Aug 2006 09:26:26 -0700
Message-ID: <1154449585.921267.33960_at_i3g2000cwc.googlegroups.com>


> Person Friend Location
> ----------------------------------
> john frank work
> bob sam home
> tommy billy school
> RMDB Query: SELECT Person from Friendships where Location = "Home"
> *Note: NOT removed from above query, since dbd's NLI doesn't implement NOT (yet).

> john (friend at work) frank
> bob (friend at work) sam
> tom (friend at work) billy
> DBD Query: (and (select person instance *) (select * (select friend at home) (select person instance *)))

> Hopefully we can now agree that in the case
> of query formulation the RM has an advantage of your system, comparing:

I agree (and have posted as such in the past) the SQL interface for RMDBs is much better (provides more functions) than the NLI (Natural Language Interface) for dbd. Currently dbd's NLI doesn't implement functions such as NOT, sum, avg, min, max, etc; and requires one to implement them in their application by loop thru a set of things returned by high-level queries. For example, the psuedo code below calculates the total age of all persons who are male. See www.dbfordummies.com/example/ex004b.asp for actual sample code.

total = 0;
q1 = Expr_Process("(and (select age instance *) (select (and (select person instance *)(select * gender male)) age *))"); while (age = Expr_Execute(q1)) {

   total = total + convertToReal (age) ; }

However as far as "basic" queries (those without sum, avg, etc), dbd's are simpler than RMDB's once we get past non-normalized data stored in one table as in this example so far. Making a conclusion at this point might be premature. First note, RMDB solution only encodes half of the bi-directional friend relationship, whereas dbd's is bi-directional. Let's add a new data requirement and see how the existing data/schema/query in RMDB and DBD are impacted. Suppose, there are now two persons named Bob instead of just one. The first/original Bob owns a Chevette (a car). The second/new Bob owns a Corvette (a car). Both Bobs are friends (bi-directional relationship) of Sam at home. Below shows how to update/add dbd's existing solution.

(create 'chevette 'car)
(create 'own 'verb)
(create bob own chevette)

(create 'corvette 'car)

(new 'bob 'person)
(create (it) own corvette)

(create (it) (select friend at home) sam) OR
(create (and (select person instance *)

                  (select * name (word1st 'bob))
                  (select * own corvette))
           (select friend at home)
           sam)

Dbd's original data/structure is unaffected. Dbd's orignal query to find persons who have friends at home is not affected :
(and (select person instance *) (select * (select friend at home) (select person instance *)))
This query now return both Bobs. If issuee via dbd's GUI, first the node for Bob with Chevette is highlighted, click Ok, then the node for Bob with Corvette is highlighted.

Please show how to adapt the RMDB solution to encode friend as a bi-directional relationship and allow for two person with same name distinguished by the car each owns.

> I also highly recommend you get a copy of "Data and Reality" by William Kent off amazon as there is some really illuminative stuff in there.

Thx, will check it out. Received on Tue Aug 01 2006 - 18:26:26 CEST

Original text of this message