NYCPHP Meetup

NYPHP.org

[nycphp-talk] Building trees

Jim Hendricks(Biz Computing) jim at bizcomputinginc.com
Thu Oct 17 10:38:37 EDT 2002


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 ---
>
>
>
>
>
>  
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20021017/f6648c2b/attachment.html>


More information about the talk mailing list