News for hackers. Stuff that matters.
Re:Subcases and Hierarchy by cjg on Wednesday September 02, 2009 @11:36AM (#800393)
The discussion of the storage of the hierarchies in the database is quite interesting.
Re:Subcases and Hierarchy by extension on Thursday September 03, 2009 @05:54AM (#802126)
Except they implemented it wrong. You are supposed to leave gaps in the numbering to add new nodes. If you use consecutive numbers then inserting a node requires renumbering all consecutive nodes.

When I was faced with this problem, I used a dynamically sized bit vector field as an id and indexed it lexicographically. When a node is inserted, it's assigned the id of its parent appended with a 0 or 1, depending on its relationship to the parent. Thus, ids are unlimited and never have to be reassigned. Selecting a subtree is just a single range search. For a non-binary tree, a vector of some other type can be used.

I got the idea from this: http://en.wikipedia.org/wiki/Surreal_numbers

Re:Subcases and Hierarchy by 83457 on Wednesday September 02, 2009 @01:22PM (#800643)
This is the first time I've run across trees/nodes in the organization of relational data. Makes a lot of sense and certainly sounds like someone was "thinking outside the box".
Re:Subcases and Hierarchy by henning on Wednesday September 02, 2009 @01:28PM (#800660)
The nested set model is a well-known workaround for storing tree-like structures in a relational database.