Hi Ian and everybody else,

Check out the book "trees and hierarchies in SQL for smarties" by Joe
Celko. ISBN: 1-55860-920-2
It gives a very good overview about how to treat trees in a SQL
database. It's really good, and it refers to the "nested set tree model"
very deeply.
I use SQL-Server and i wrote a couple of triggers that keep my lft, rgt
and lvl values up to date. If you need them, just email me at
[EMAIL PROTECTED]

Btw. The trick about not having to update so many records in a nested
set tree model if you insert a node near to the top is that you do not
use gaps with the size of 1 between the bottom leafs. You can use steps
of eg. 10. So if you have to insert a node to the left of the topmost
treenode with the left value of 1 and the left value of the first
subordinate of 11 you can just insert the new record with the lft and
rgt values of 2 and 3 without any further update. (check out Chapter 5
in the mentioned book called "frequent insertion trees")

<cfgreetings from="[EMAIL PROTECTED]" to="reader" location="bern"
country="switzerland" function="railo core developer" message="merry
xmas">

-----Urspr�ngliche Nachricht-----
Von: Ian Buzer [mailto:[EMAIL PROTECTED] 
Gesendet: Donnerstag, 23. Dezember 2004 14:51
An: CF-Talk
Betreff: Re: In One?


>You could set your table up in a "modified preorder tree traversal", so

>each node has a "LFT" and "RGT" numeric value. I've done this in 
>several instances and it works great.

Hey, thanks Dov, that's lovely.

As far as I understand it so far, it does have the snag that if you make
a change near the top of the hierachy, a whole lot of data below has to
be updated.

Also, in this particular instance, I'm importing the category heirachy
from another app on a daily basis which uses the other schema, so I'm
probably looking at a long process to convert it from one schema to
another during the import.

Ian



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Special thanks to the CF Community Suite Silver Sponsor - New Atlanta
http://www.newatlanta.com

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:188696
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to