Trees in SQL(intelligententerprise.com)
intelligententerprise.com
Trees in SQL
http://www.intelligententerprise.com/001020/celko1_1.jhtml;jsessionid=3DFR02341QLDEQSNDLRSKHSCJUNN2JVN?_requestid=32818
2 comments
The problem with the nested sets is that changing the tree can be slow. You need to update all the nodes with right/left pairs after the insertion/deletion point.
There are two more methods which can be of interest and don't suffer from this problem:
"Materialized path model" (which uses strings to encode the whole path to a node) and the "nested intervals tree encoding" (which could be the ideal solution if someone manages to implement it. I couldn't find a decent implementation):
http://arxiv.org/ftp/cs/papers/0402/0402051.pdf
very cool. An interesting method for flattening trees.