Nick,
I went searching for this recently too. Apart from the left/right id trick, you can also add the path as a field of the record. Thus:
ID PARENT_ID NAME PATH
1 null root root
2 1 A root.A
3 1 B root.B
4 2 X root.A.X
etc...
Now its easy to find all children of a given node:
Select * from NODES where path like 'root.A.%' // finds all children of root/A

To check if a record has a given ancestor:
path.startsWith(ancestor.path)

Of course, if you want to move the folders around, then you will have to update many records. Personally, I can't think of a clever piece of SQL to do that, but then again, I'm no expert.

If you are worried about using large names, you could use stringified ids as the path elements (e.g. node 4 would have a path: 1.2.4)

Lastly, I never bookmarked the link, but it should be easy to google.
Ciao,
Jonathan O'Connor
XCOM Dublin
Inactive hide details for Tapestry Stuff <[EMAIL PROTECTED]>Tapestry Stuff <[EMAIL PROTECTED]>


          Tapestry Stuff <[EMAIL PROTECTED]>

          08/09/2005 20:27

          Please respond to
          "Tapestry users" <[email protected]>

To

Tapestry users <[email protected]>

cc


Subject

Presenting really large trees

Hi, wondering if anyone has come up with a nicer way to present LARGE sets
of hierarchical data. Trees are fine but the large set makes the tree
unwieldy. We have been using tacos tree for a long time but now the set has
grown so large as to cause us grief with page layout and looong db queries.
I think that persisting the tree is out of the question as the set is too
large.

Any ideas?

--
Nick




*** XCOM AG Legal Disclaimer ***

Diese E-Mail einschliesslich ihrer Anhaenge ist vertraulich und ist allein für den Gebrauch durch den vorgesehenen Empfaenger bestimmt. Dritten ist das Lesen, Verteilen oder Weiterleiten dieser E-Mail untersagt. Wir bitten, eine fehlgeleitete E-Mail unverzueglich vollstaendig zu loeschen und uns eine Nachricht zukommen zu lassen.

This email may contain material that is confidential and for the sole use of the intended recipient. Any review, distribution by others or forwarding without express permission is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.

Reply via email to