Re: Tree (forest) design

From: Mikito Harakiri <mikharakiri_at_iahu.com>
Date: Fri, 5 Mar 2004 14:16:06 -0800
Message-ID: <P772c.31$zW4.162_at_news.oracle.com>


"Neo" <neo55592_at_hotmail.com> wrote in message news:4b45d3ad.0403051341.73fd1e9f_at_posting.google.com...
> Below is one way to represent Ex076's data in RDM. Note, each thing in
> the hierarchy can be of different type. Each thing in the hierarchy
> can have multiple parents.

So you have a graph, not a tree. Why do you display it as a tree in your GUI? To confuse the user?

> Each thing is nomalized. Solution is
> NULL-less (for the limited data shown below). The solutions you and
> Mikito provided don't work with this level of generalization.

While it's perfectly true that Celko's solution doesn't work for graphs in general, the other methods still would.

> T_Hierarchy
> ParTblID ParTblRowID ChldTblID ChldTblRowID
> ->T_God ->MyGod ->T_Force ->Army
> ->T_Force ->Army ->T_Person ->John
> ->T_God ->MyGod ->T_Church ->Trinity
> ->T_Church ->Trinity ->T_Person ->John
>
> T_Table
> 1 T_God
> 2 T_ArmedForce
> 3 T_Church
> 4 T_Person
> 5 T_Computer
> 6 T_Dog
>
> T_God
> 10 MyGod
>
> T_Force (Armed Forces)
> 11 Army
>
> T_Church
> 12 Trinity
>
> T_Person
> 13 John
> 14 Mary
> 15 Luke
>
> T_Computer
> 16 Laptop1
>
> T_Dog
> 17 Fido

I can't possibly see what have you acomplished by breaking down the schema into multiple tables. Every table (except hierarchy) has <id, name> signature, so that they all can be unified into a single <id, type, name> relation. Now if I add parent id reference then the hierarchy table signature becomes <id, type, name, parent_id>. To clarify for dummies, I'll insert couple of records there:

insert into hierarchy values (1,T_God, MyGod, NULL) insert into hierarchy values (2,T_Force, Army, 1)

You aren't going to criticise me for that NULL in the root record, aren't you? Homework problem: normalize the design into Edges and Nodes tables that don't have any NULLs. Received on Fri Mar 05 2004 - 23:16:06 CET

Original text of this message