How to implement trees using the nested set model?

Posts   
 
    
Posts: 2
Joined: 27-Feb-2006
# Posted on: 27-Feb-2006 11:13:33   

Since I havn't found the answer in the documentation (as far as I've read it) or in the forum itself...

How would I implement a tree data structure using the nested set model? As far as I currently understand it, I would retrieve the nodes from the table as if they were a flat data structure, and then rearrange them to a tree in an object build on top of the generated classes.

Is there any better way to do this?

Kind Regards Stephan

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 28-Feb-2006 02:32:35   

I don't know of a better way using the nested set model. We currently have some that are adjacency lists and we use prefetch paths to fill the objects in a hierarchy directly from the database.

Posts: 2
Joined: 27-Feb-2006
# Posted on: 28-Feb-2006 10:24:04   

Thanks for the answer.

Do you have or know of any experience when the additional effort to use the nested tree model would pay back in terms of runtime behavior, such as number of nodes in the hierarchy to retrieve, or depth of the tree, or the need to frequently query subtrees?

Do I get it correctly that the main problem with the nested tree in order to support it in LLBLGen would be a) lack of customers requests as it is not that commonly used and b) that insert and delete operations are not global operations?

In your opinion, would implementing it using stored procedures provide some advantages over the approach described previously?

Kind Regards + Thanks again! Stephan

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 01-Mar-2006 02:51:46   

I'm sorry I've not implemented the Nested Set Model. I looked at it a bit and it reminded me of a similare approach by Celko that has been mentioned on these forums before. Here is a link to newsgroup post describing the technique http://groups.google.com/group/comp.databases.theory/msg/25acd5da2a3110e7?dmode=source

These are the forum posts that were being discussed that were addressed using Celko's method.

http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=3208 or: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=2336