Well a good tip for me was that the difference between two left values 
is not one but for example 10. In this case you can update your left & 
right values without having to update all the left & right values larger 
than a particular one when you insert a record or delete one. You can 
then reorganize your tree once a day and then you have your usual 
differences again. So check the following example:

Classical Nested Set:
Node    Left    Right
A       1       10
? B     2       5
 | ? C  3       4
? D     6       9
 ? E    7       8


If you now insert a new node F below the node B you have to update 
several nodes:
Node    Left    Right
A       1       12
? B     2       7
 | ? C  3       4
 | ? F  5       6
? D     8       11
 ? E    9       10

In this particular case you had to update all nodes!

The new more spaced nested set would look like:
Node    Left    Right
A       10      100
? B     20      50
 | ? C  30      40
? D     60      90
 ? E    70      80


An insert of the Node F below the node B would only require one insert:
Node    Left    Right
A       10      100
? B     20      50
 | ? C  30      40
 | ? F  41      42
? D     60      90
 ? E    70      80


You see the rest of the nodes keep their values. Of course after several 
insert the tree might get crowdy, but with a little logic, you can 
manage this quite easily and get rid of tons of updates.
Another good practice is to keep the left & right values in a separate 
table. Then only these values get updated and the main Table where the 
tree resides is untouched. I use a combination of nested set and parent 
child values. In this case I can reorganize the tree at any time.

BTW: a very good book about nested set tree model is Joe Celko's "SQL 
for Smarties". He has released one about hierarchies in SQL as well. You 
might want to have a look at it.

Greetings from Switzerland
Gert Franz
Railo Technologies GmbH
[EMAIL PROTECTED]
www.railo.ch

Join our Mailing List
german:    http://de.groups.yahoo.com/group/railo/
english:   http://groups.yahoo.com/group/railo_talk/
linked in: http://www.linkedin.com/e/gis/71368/0CF7D323BBC1



Mike Kear schrieb:
> @Brad:  thanks for the advice.  Throws my plans into a spin, but not
> as much as it might have it if the whole shebang gor fubared.  (I
> didnt know 'fubar' was a verb!).
>
> @Mark: It's MSSql 2005. Thanks for the tip Mark,  I'll have a look at that.
>
> What is going to happen is event type {a} happens (lets say it's a
> sale).  That triggers a default action plan of umpteen things that
> have to follow based on that event, documents that have to be filed,
> people notified, approvals gained etc, then the the default plan has
> to be modified to allow for the specifics of this particular
> transaction.
>
> So the event has to trigger the generation of a whole heirarchy of
> maybe up to 50 things that have to happen, some of which rely on
> previous things being done
>
> Cheers
> Mike Kear
> Windsor, NSW, Australia
> Adobe Certified Advanced ColdFusion Developer
> AFP Webworks
> http://afpwebworks.com
> ColdFusion, PHP, ASP, ASP.NET hosting from AUD$15/mont
>
>   
>


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312749
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to