Re: yet another hierarchy model

From: Vadim Tropashko <nospam_at_newsranger.com>
Date: Tue, 16 Oct 2001 22:26:23 GMT
Message-ID: <ju2z7.31942$ev2.39130_at_www.newsranger.com>


In article <eef24980.0110161354.7eb13a84_at_posting.google.com>, KWillets says...
>
>Vadim Tropashko <nospam_at_newsranger.com> wrote in message news:<Urmx7.24985$ev2.33971_at_www.newsranger.com>...
>> Here is one more way to represent hierarchy: just store depth-first sequence
>> number and level (simple, indeed!).
>>
>(...until one needs to delete or insert a node.)
>
>How about:
>
>1. Assigning unique prime numbers to all leaf nodes, and assigning
>each intermediate node the product of its subordinates.

Albert (2*3?)
/ \
/ \
Bert (2) Chuck (?)
\
\
Fred (3)

What to assign to Chuck? 3? He is not on leaf node, however.

>2. Using a bitmap with each bit assigned to a leaf node, and or'ing
>the things together at intermediate nodes.
>
>3. Embedding the tree on a binary tree and keying each node by the
>bitstring which indicates its position in the B-tree, eg
>
> A ---> A
> / | \ / \
>B C D B () () is omitted
> / \
> C D
>
>node key
>A 0
>B 00
>C 010
>D 011
>
>(Omitting the 01 node means that 01* nodes are children of 01's
>parent, etc.)

This is essentially materialized path. The other coding schema for the left tree would be:

node key

A        A
B        A.B
C        A.C
D        A.D

I would have to use substring operations, instead of bit operations in your encoding or numeric operations in Celko's approach.

This approach is resilient to insertion/deletion of nodes, indeed.

>This kind of thing can go on and on....

All those cases empower a tree with some global coding schema, so that tree operations could be expessed with "group by" and aggregates. Interestingly, the adjucency list model is the only one with local coding. Received on Wed Oct 17 2001 - 00:26:23 CEST

Original text of this message