A common technique to manage hierarchical data in a relational database is to use an "Adjacency List" model, where you have both an ID column and a Parent ID column in a table. This is easy to understand and maintain but can be difficult or inefficient when you want to retrieve hierarchies of records.
The "Nested Set" model provides an alternative technique for managing this kind of data and is more efficient at reading a hierarchy but requires a little more work for inserts, updates, deletes and moves.
This project provides a library of ColdFusion code that you may like to use to help manage your hierarchical data using the nested set model.
This project can be downloaded from RIAForge:
The documentation for this release:
Changes in this release
This release involved a significant rewrite of the library’s structure, but I kept the API as similar as possible.
The main changes include:
- Introduction of a NestedSetTreeTable object, which allows the creation of multiple NestedSetTree objects per table. So the creation of the NestedSetTree objects has now changed.
- Introduction of a Node object to replace the previous struct nodes. So previous code that referred to node.id, node.l and node.r should be changed to use node.getId(), node.getLeft() and node.getRight()
Please add any comments/problems regarding this release to this entry, thanks.