Attention: We are retiring the ASP.NET Community Blogs. Learn more >

Looking for best practices with hierarchical data

Now that we have the glorious TreeView and site mapping controls in v2 of ASP.NET, I'm curious to know if anyone has published some kind of best practices regarding the extraction of hierarchical data from a database.

Anyone?

4 Comments

  • I'm currently working through this problem myself actually, the book 'Joe Celko's Trees and Hierarchies in SQL For Dummies' is just awesome for this covering pretty much every which way you can do this. In addition to the sitepoint one Tommi mentioned above, this one: http://www.intelligententerprise.com/001020/celko.jhtml?_requestid=273960

    covers Joe Celko's approach using 'Nested Sets'. It is still worth getting the book though as he gives more recipes for stuff like updating and how to avoid problems with frequently changing sets.

  • Should be 'Joe Celko's Trees and Hierarchies in SQL For Smarties' :-)

  • Hi



    I created an SQL sproc quite a while ago which dealt with this. Basically you pass a temporary table of items with just IDs and Parent IDs (and some other extra data), and then the sproc sorts the hierarchically for you with the exact tree index that the nodes would be in a .NET treeview. Therefore you have no recursion necessary in your .NET code at all, you just create the nodes as you iterate over the dataset.



    - Brett

  • http://www.sqljunkies.com/How%20To/D7CAED46-CCAC-4FF7-B528-B2E9A274B71C.scuk



    Best way I've seen to deal with this sort of data.

Comments have been disabled for this content.