We’re thinking of using PEAR’s NestedSet library on the Seagull project as an improvement on the current MySQL-only tree manipulations offered by HTML_TreeMenu.
Nested sets are more complex to setup than the simple id-parent id paradigm of the adjacent list method, but running typical queries to determine leaf nodes, paths, etc are much easier.
This article on modeling trees has a good overview of the difference between the two approaches, thanks to Andy Crain for pointing it out.
update: the quoted link has since been pulled, but check out this article on modified preorder tree traversal which gives similar background info on the subject.








November 13th, 2003 at 8:21 pm
At the end of the day you more often than not end up storing infromation in nested as well parent id format.
The main reason is that while nested tree logic is seductive it is incredebly difficult to handle some task which are trivial in parent – child trees (or whatever they are called )
Like in a nested tree try getting just the next level childs OR inserting a node…