Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> comp.databases.theory -> Re: Ordered result set with path enumeration

Re: Ordered result set with path enumeration

From: Lennart Jonsson <lennart_at_kommunicera.umea.se>
Date: 19 Aug 2003 02:29:29 -0700
Message-ID: <6dae7e65.0308190129.6e7a8d5@posting.google.com>


"Mikito Harakiri" <mikharakiri_at_ywho.com> wrote in message news:<msb0b.24$hi4.63_at_news.oracle.com>...
> "Vadim Tropashko" <vadimtro_at_yahoo.com> wrote in message

[...]

>
> > 6. For any nodes A and B we write A > B whenever
> > i. B is parent of A or
> > ii. there exists node B' which is an ancestor of B,
> > and A' which is an ancestor of A,
> > and both A' and B' having the same parent,
> > and A' > B'
> > 7. For any node A, the depth first enumeration number is the number of
> > nodes that are predecessors of A with the ordering defined at the
> > step# 6.
>
> create view DepthFirst as (
> select boss lesser, emp greater from OrgChart
> union
> select distinct n1.name, n2.name
> from nodes n1, nodes n2, nodes n01, nodes n02
> where n01.reportsTo = n02.reportsTo and n01.name < n02.name
> and (n01.name=n1.name or n01.name in
> (select boss from OrgChart where emp = n1.name))
> and (n02.name=n2.name or n02.name in
> (select boss from OrgChart where emp = n2.name))
> )

Ahh, very elegant. I never thought of that way to define the ordering relation. I was more into calculating the size of each subtree s, and then number the next sibling of s according to that. This is clearly much better

/Lennart, a bit more enlightened

--
the above email no longer works due to spam.
values'lennart'||CHR(46)||'jonsson'||CHR(64)||'enlight'||CHR(46)||'net'
Received on Tue Aug 19 2003 - 04:29:29 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US