Re: Nested Sets and custom sorting
From: --CELKO-- (jcelko212_at_earthlink.net)
Date: 08/05/04
- Next message: Thomas Scheiderich: "DBO/Permissions questions"
- Previous message: Lance: "Return records through sp_addlinkedserver"
- In reply to: Mark: "Re: Nested Sets and custom sorting"
- Next in thread: Dan: "Re: Nested Sets and custom sorting"
- Messages sorted by: [ date ] [ thread ]
Date: 4 Aug 2004 20:54:33 -0700
Here is the link on Amazon.com for my new book on "Trees & Hierarchies
in SQL"
I have routines for swapping siblings, inserting in any position, etc.
in the Nested set model, so you can give the tree whatever structure
you wish. The push-down stack tree traversal I give on the news
groups uses collation order on the sibling node ids -- leftmost son is
also the one with the minimum value.
>> In my case, the ordering of sub-nodes depends on the value of the
ListOrder and SortIndex fields of a node. And I can't find a good way
of inserting the nodes in the desired order without using nested
cursors or such. <<
The general idea is that given a new node that you wan to place under
a parent and between two existing siblings, you make a gap. The gap
is made by adding 2 to each lft and rgt values to the right of the
insertion point. Same idea for inserting a new subtree, but with a
bigger gap.
There are also routines for swapping sibling subtrees. I am in the
middle of packing for a move, so I cannot get to my manuscript
diskettes, but the swapping code has be posted in newsgroups.
- Next message: Thomas Scheiderich: "DBO/Permissions questions"
- Previous message: Lance: "Return records through sp_addlinkedserver"
- In reply to: Mark: "Re: Nested Sets and custom sorting"
- Next in thread: Dan: "Re: Nested Sets and custom sorting"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|