NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Have you looked at nested sets? (Score:1)
Depending on the size of the tree, I've found that the nested sets representation is very nice for queries.
The query that you need is given as an example in this page:
http://dev.mysql.com/tech-resources/articles/hierarchical-data.html [mysql.com]
(Although this is a mysql.com site, there is nothing MySQL specific with the solution)
The problem with nested sets is updates: they might change a large number of records - worst case, inserting a new node at the left-most place will update all the rows.
But smaller trees, they work very very well.
life is short
Reply to This