[nycphp-talk] Building trees
(kris)janis p gale
sharpwit at hotmail.com
Fri Oct 18 00:42:41 EDT 2002
anyone see my post?
i replied with one of my solutions for displaying trees
yesterday but didn't see it echoed on the list...
just checking that it was received.
----- Original Message -----
From: Jim Hendricks <jim at bizcomputinginc.com>
To: NYPHP Talk <talk at nyphp.org>
Sent: Thursday, October 17, 2002 10:38 AM
Subject: Re: [nycphp-talk] Building trees
> Hey, thanks, I recalled reading the Celco articles on trees years ago,
> didn't know they could still be obtained, thanks. This may be my best
> bet yet. Celco can be deep reading, but worth it in the end. Just a
> perusal of this article and the ensuing 2 shows that Celco put a lot of
> thought into it which allows doing this tree stuff at the SQL Server end
> in standard SQL without burdening the application. Just grab the data,
> iterate for display. This is the kind of solution I was looking for.
> Thanks big time. Now if I can just understand all the in's and out's
> of Celco's stuff...
>
> Jim
>
> Steve Manes wrote:
>
> >At 01:12 PM 10/16/2002 -0400, Jim Hendricks wrote:
> >
> >
> >>I know this is a SQL question, but since most apps deal with SQL, I
> >>figured I'ld ask here since the app is using PHP and MySQL.
> >>
> >>I have a table that establishes an entity that may have a parent from
> >>the same table. I would like to display the data in a tree format where
> >>all items with a ParentID of 0 ( no parent ) are listed with children
> >>indented under the parent. The nesting can be infinite, but
> >>realistically will only be 2 or 3 levels deep. I can see how to do this
> >>through a whole series of queries, but can see how the performance of
> >>such a design could be very poor if there is a lot of items.
> >>
> >>
> >
> >SQL deals in result sets and is unfortunately not a good tool for working
> >with directed graphs, of which trees are one such data structure. I've
> >been working casually on this for a couple of years without much
> >success. There are alternative methods of representing trees in SQL as
> >nested sets, or at least it's possible in Oracle. But it's not
> >pretty. Here's a Joe Celko article I've archived, which is the best I've
> >found on the topic of generating trees with SQL:
> >
> >http://www.dbmsmag.com/9603d06.html
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
>
>
>
> --- Unsubscribe at http://nyphp.org/list ---
>
More information about the talk
mailing list