Re: Nested sort, trying again




Bob Stearns wrote:
....
> In this case the tree is sorted in the order I want to present it to my
> users. Consider the tree z(y(x,w),v(y(t,s))) which would have a similar
> representation to the first on but which I wish to present to my users as:
>
> z
> v
> u
> s
> t
> y
> w
> x
> The question is: Is there an easy (relatively) way to produce this sort
> without a recursive sql user defined function?

No, you cannot do that in the standard SQL even resorting to tricks
like nested intervals or some such. What you want to do is the a
DFS(depth-first search) with siblings ordered by their names.

Oracle's proprietary 'connect by' will do that easily with the usual
(child, parent) representation. DB2's recursive query however won't
because it performs a BFS (breadth-first search.

.



Relevant Pages

  • Re: Nested sort, trying again
    ... representation of a tree; he has an entire book devoted to it: _Trees and Hierarchies in SQL for Smarties_; ISBN 1-55860-920-2. ... In this case the tree is sorted in the order I want to present it to my users. ... Is there an easy way to produce this sort without a recursive sql user defined function? ...
    (comp.databases.theory)
  • Re: Three Kinds of Logical Trees
    ... >>> That strikes me as a nonstardard definition of the use of metadata, ... >> metadata & data from an RDBMS into an xml dom tree. ... I think this is just a representation issue. ...
    (comp.databases.theory)
  • Re: Problem for physicalist evolutionists
    ... then the processing did indeed represent which fairy lights would go ... How could the robot brain in a vat ... looked at a tree. ... to of had the representation of a tree, ...
    (talk.origins)
  • Re: Problem for physicalist evolutionists
    ... then the processing did indeed represent which fairy lights would go ... How could the robot brain in a vat ... looked at a tree. ... to of had the representation of a tree, ...
    (talk.origins)
  • Re: No TABLES in html. No hacks in CSS. Any layout possible, crossbrowser. Try it.
    ... *tree* that is still a semantically incorrect representation of the ... The DOM tree isn't subject to the requirements of the HTML DTD. ...
    (comp.infosystems.www.authoring.html)