Re: Tree (forest) design

From: Neo <neo55592_at_hotmail.com>
Date: 5 Mar 2004 12:47:18 -0800
Message-ID: <4b45d3ad.0403051247.6d449eb1_at_posting.google.com>


> > Can you prove that your steps actually work by producing a "Nearest
> > Common Ancestor Report" equivalent to that shown at
> > www.xdb1.com/Example/Ex076.asp starting from the same normalized,
> > null-less data? Can you implement your steps using MS Access or
> > SQL-Server so that we can verify it?
>
> Let me steal code from one of my books, the parts explosion of a
> Frammis ina nested sets model:

Your solution won't work for Ex076. Ex076 allow a user to enter normalized and NULL-less data representing any hierarchy. The hierarchy can consists of different type of things (ie church, person, dog, etc). Each thing in the hierarchy can have any number of parents. For any such user created hierarchy, given the root, it generates a "Nearest Common Ancestor Report".

If I enter the equivalent hierarchy in a typical db and specify the root, your (and Mikito's) code will not generate anything, among other reasons, neither handles a hierarchy where the parent and child are from different tables.

Try to represent the data in Ex076 in a normalized and NULL-less manner. If you can just accomplish this (you will be the first, not that it is difficult), then you will see why your solution won't work. Below is the data to represent. Note, don't explicitly represent the relators "obey", "isa" or "is". They can be implied.

force isa thing. (Force is an abbreviation for Armed Forces) army isa force.

church isa thing. (In RDM, a table named church) trinity isa church. (In RDM, a tuple with name equal to trinity)

person isa thing.    (In RDM, a table named person)
john isa person.     (In RDM, a tuple for john)
mary isa person.     (In RDM, a tuple for mary)
luke isa person.     (In RDM, a tuple for luke)

age isa thing.       (In RDM, a table named age)
35 isa age.          (In RDM, a tuple for 35)
john is 35. (In RDM, relate tuple person/john with age/35, via mapping table)

weight isa thing.
130 isa weight.
mary is 130.

color isa thing.
red isa color.
luke is red.

dog isa thing.
fido isa dog.

computer isa thing.
laptop1 isa computer.

obeys isa relator. (The relator obey is used to build the command hierarchy, XDb1 specific)

god isa thing.
god equals god. (XDb1, specific)
it is obeys. (Assoc relator with command hierarchy root, XDb1 specific)

army obeys god.
trinity obeys god.
john obeys army.
mary obeys army.
mary obeys trinity.

luke obeys trinity.

laptop1 obeys john.
laptop1 obeys mary.

fido obeys john.
fido obeys mary.
fido obeys luke.

The resulting hierarchy is shown in figure 2 at www.xdb1.com/Example/Ex076.asp

The following is a list of possible base tables to impliment Ex076 in RDM.

T_CmdHier
T_God
T_ArmedForce
T_Church
T_Person
T_Dog
T_Computer
T_Age
T_Weight
T_Color

To make the example even simpler, you can ignore properties of persons. Received on Fri Mar 05 2004 - 21:47:18 CET

Original text of this message