Re: Other tree representations in SQL
Date: Fri, 6 Dec 2002 17:29:07 +0100
Message-ID: <asqioj$or7$02$1_at_news.t-online.com>
Alfredo Novoa wrote:
> >> var Tree = real relation { N Char, P Char } key { N, P };
> >> Tree := relation { tuple { 'A', 'A' }, tuple { 'B', 'A' }, tuple { 'C', 'A' },
> >> tuple { 'D', 'B' }, tuple { 'E', 'B' }, tuple { 'F', 'C' },
> >> tuple { 'G', 'C' } };
>
> >How would you rename the data part of a Tree node, let's say
> >if "A" had to become "Z"?
>
> var Tree = real relation { N Char, P Char } key { N, P } foreign key {
> rename P as N } references Tree on update cascade;
>
> update Tree where N = 'A' { N := 'Z' } ;
Hey, nice feature.
> >Joe was looking for three different tree traversals and for
> >two queries. Where are they in your example?
>
> The 5040 different transversals are here:
>
> Tree { N };
No.
The process of visiting all nodes is "traversal" without "ns".
Since your solution is not a Tree, because it does not differentiate between preceding and subsequent nodes, it can not be traversed.
"Tree {N}" does nothing at all.
> The parent of F here:
>
> Tree { P } where N = 'F';
>
> The childs of A:
>
> Tree { N } where P = 'A';
>
> The descendants of B:
>
> ((TClose Tree) where P = 'B') { N } ;
Fine.
I would still love to see a complete solution and a system to run it on.
Kind regards,
Carl
-- Carl Rosenberger db4o - database for objects - http://www.db4o.comReceived on Fri Dec 06 2002 - 17:29:07 CET