Does anyone know how to specify a mapping for a tree structure as a nested set?
The database table and corresponding data would look like:
<snip>
CREATE TABLE Personnel
(emp CHAR(10) PRIMARY KEY,
salary DECIMAL(6,2) NOT NULL,
left INTEGER NOT NULL,
right INTEGER NOT NULL);
Personnel
emp salary left right
====================
'Jerry' 1000.00 1 12
'Bert' 900.00 2 3
'Chuck' 900.00 4 11
'Donna' 800.00 5 6
'Eddie' 700.00 7 8
'Fred' 600.00 9 10
</snip>
It's an eficient way to model a tree structure where you can find a part of the three with just one single SQL query. This is in contrast with the recursive query needed for a normal child/parent relationship where you would have a table with a parent_id column.
This example comes from an article from DBMS
http://www.dbmsmag.com/9603d06.html
Where would extra methods like 'getAllSiblings' belong? Would they be put in the model class?
All feedback is welcome.
Best regards,
Mark