views:

829

answers:

1

I am building a hierarchy structure from scratch and I am trying to determine the best route to take. I found the following link below from another StackOverflow question:

Nested Set Model

I like the idea of nested sets and have begun to build my database, based on this pattern. I am now unsure how to query the data out in such a way that I will easily be able to bind to a control, such as the TreeView. I will need to be able to reorder and commit the data back as well. Any suggestions?

+1  A: 

SQL 2005 added support for recursive queries. I'm using a recursive query to return a tree of data that populates a TreeView. For each record, I find the matching parent node from the TreeView and add its new child.

For updates you could serialize the tree to XML, then use the XML features in sql 2005 to run an "update" statement.

David
What about your data allows ASP.NET to know it's a "tree of data" prior to data binding?
Brian David Berman
I do the binding manually.
David
Do you know if your data is using the Adjanceny List Model or the Nested Set Model (or something else)?
Brian David Berman
Good point. I guess I'm using the Adjacency List Model.
David