Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 possible to move nodes in Nested Set Model?

Author  Topic 

deviant69
Starting Member

7 Posts

Posted - 2004-06-25 : 09:35:17
Hi,

i develop a MaxDB. i work with the Nested Set Model and my question is, does anybody know if it is possible to move nodes inside this Nested Set Model, and if it is possible, if there is an example.

thanks in advice
deviant69

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2004-06-25 : 09:55:39
little more info on your model... table layout, sample data, and result example would be great

Corey
Go to Top of Page

deviant69
Starting Member

7 Posts

Posted - 2004-06-25 : 10:04:44
the table just has 3 columns:

NAME VARCHAR(10) | LEFT INTEGER | RIGHT INTEGER

i load the table into a treeview and now i wanna move a node:

NAME | LEFT | RIGHT
Root | 1 | 8
1 | 2 | 3
2 | 4 | 5
3 | 6 | 7

now i wanna move 3 in 1, the result should be:

NAME | LEFT | RIGHT
Root | 1 | 8
1 | 2 | 5
3 | 3 | 4
2 | 6 | 7

this is a simple sample, but it shows how difficulte it is.
at the moment i am able to move 2 in 1, but if i try 3 in 1, i get wrong values and the tree is destroyed

deviant69
Go to Top of Page

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2004-06-25 : 11:05:26
I don't understand your tree. Are the left and right two branches? If so, then the result you want is a disconnected tree as there is no relationship from 5 to anything else.

Maybe this will be of some help:
http://www.seventhnight.com/treestructs.asp

Corey
Go to Top of Page

deviant69
Starting Member

7 Posts

Posted - 2004-06-25 : 12:38:43
i made a little example:

[url]http://mitglied.lycos.de/westy69/tree.jpg[/url]


i heard, that in Joe Celko's book: SQL for Smarties is a solution. he realeased many columns, so i thought one could have a solution, but i was wrong. so i tried to find a solution by myself, but that became little harder than i thought.


deviant69

Go to Top of Page

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2004-06-25 : 12:46:38
Take a look at the link i sent you... it should cover what you need to do to manage a tree.

One problem I see with your currect example, is that you don't seem to managing the relationships between each name instance.

Corey
Go to Top of Page

deviant69
Starting Member

7 Posts

Posted - 2004-06-28 : 06:21:42
like is said, it was just a sample. i handle much more information, but they are not important for the example.

your link is not exactly what i was looking for, it is not a mutli parent tree, but finally i found a solution myself. thanks for your tips

deviant69
Go to Top of Page
   

- Advertisement -