http://www.perlmonks.org?node_id=472658


in reply to Re: Tree Structure and Db
in thread Tree Structure and Db

As the author stated, this structure is good for trees that are mostly static.

In case the tree can be updated, performance becomes an issue. Even a simple operation as to insert a leaf node, could cause you to insert multiple rows (average number of rows inserted equals average depth of all pathes, and in the worst case, the number of rows get inserted is the length of the deepest path.)

Look at one more operation: to move a subtree to be under a new parent. if you only store the immediate parent-child relationship, you only need to modify 1 row, but if you store all ancestor, you will need to modify multiple rows for each node in the subtree (basically to modify all relationships towards a node that is above the root of the subtree.)

Data integraty could also be an issue, a simple coding mistake can spread dirty data all over the place, not just an isolated spot.

Replies are listed 'Best First'.
Re^3: Tree Structure and Db
by ikegami (Patriarch) on Jul 06, 2005 at 03:00 UTC
    Thanks for expanding on this. I intended to do so, but didn't get get a chance 'til now. That is exactly what I meant by my comment.