OFGemini
asked on
how to Validate Hierarchy in a Nested Sets Model
Hello Experts,
I store Hierarchical data in SQL server using the Nested sets model. After editing my tree (moves, adds, deletes...), how do I validate that the hierarchy in my Nested Sets Model is valid still? I want to ensure that I don't lose any branches of my tree.
Thanks,
OFGemini
I store Hierarchical data in SQL server using the Nested sets model. After editing my tree (moves, adds, deletes...), how do I validate that the hierarchy in my Nested Sets Model is valid still? I want to ensure that I don't lose any branches of my tree.
Thanks,
OFGemini
ASKER
jogos,
Yes, how do you walk through the tree? When you walk through the tree wouldn't you only find 'not loose items' only?
Yes, how do you walk through the tree? When you walk through the tree wouldn't you only find 'not loose items' only?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
how do you query for gaps?
I am not a SQL expert but I doubt that finding a query for gaps is possible.
To check for the duplicates/gaps, what I would do is using a loop to fill all the the left-right values as keys of an array.
Then, using a second loop, I would check if each key is equal to the previous key +1.
In the end, the array should contain values = 2x the count() of the array and the first value should be 1.
To check for the duplicates/gaps, what I would do is using a loop to fill all the the left-right values as keys of an array.
Then, using a second loop, I would check if each key is equal to the previous key +1.
In the end, the array should contain values = 2x the count() of the array and the first value should be 1.
- report problems
- move loose ends to a 'loose end' hierarchy