These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Tree structrue as nested set
PostPosted: Thu Dec 28, 2006 6:11 am 
Newbie

Joined: Thu Dec 28, 2006 6:00 am
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.