Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I am trying to combine C# and SQL2005 for an application which need to have tree view control.

One of user requests is to that tree view can user friendly grow into infinite dept of child nodes. That data should be stored into database and at user request i need to draw again tree view whit parent and child nodes as it user was edited and arranged before.

How I should design my table(s) that can easily grow at two axes of tree view.

share|improve this question
1  
1  
@CodeCanvas You should answer not comment so I can select this as an answer. –  adopilot May 7 '12 at 7:11
    
I am not adding anything useful to the existing link articles, so its ok :) –  user8611 May 7 '12 at 7:37

1 Answer 1

What we have always done is do it as a self join, with a parent_id which points to the parent. This has the advantage of being simple, easy to work with, etc. Of course it also requires recursion and WITH RECURSIVE CTE's. It is easy to work with and as long as you are not working at huge depths and lots of records it performs well (note you can generate to a set depth and then fetch more records when a user expands if you want).

share|improve this answer
    
Have you seen the concept of depesz tree? –  dezso Sep 9 '12 at 14:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.