![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
What are my options for table/db designs to model an organization chart. Parent/child/siblings root/leaves ideas? How can depth or "layers deep" be handled? I haven't had to think about this for awhile and all of the sudden I have people asking me questions about using queues to simplify hiearchical or binary tree designs to avoid recursive descent parsers. A performance thing I hear. Also I am becoming aware of my own intuitive "adjacency modeling" that looks back into itself. My ID calls your ID in the same table. I think this might be part of the recursive problem I think I want to avoid. I have worked with some pretty nasty database designs in the past where performance got severely compromised. thank you for any ideas or questions to help me thing about this. -greg |
#3
| |||
| |||
|
|
What are my options for table/db designs to model an organization chart. Parent/child/siblings root/leaves ideas? How can depth or "layers deep" be handled? I haven't had to think about this for awhile and all of the sudden I have people asking me questions about using queues to simplify hiearchical or binary tree designs to avoid recursive descent parsers. A performance thing I hear. Also I am becoming aware of my own intuitive "adjacency modeling" that looks back into itself. My ID calls your ID in the same table. I think this might be part of the recursive problem I think I want to avoid. I have worked with some pretty nasty database designs in the past where performance got severely compromised. thank you for any ideas or questions to help me thing about this. -greg |
#4
| |||
| |||
|
|
What are my options for table/db designs to model an organization chart. Parent/child/siblings root/leaves ideas? How can depth or "layers deep" be handled? I haven't had to think about this for awhile and all of the sudden I have people asking me questions about using queues to simplify hiearchical or binary tree designs to avoid recursive descent parsers. A performance thing I hear. Also I am becoming aware of my own intuitive "adjacency modeling" that looks back into itself. My ID calls your ID in the same table. I think this might be part of the recursive problem I think I want to avoid. I have worked with some pretty nasty database designs in the past where performance got severely compromised. thank you for any ideas or questions to help me thing about this. -greg |
#5
| |||
| |||
|
|
I've had good performance with the adjacency model by using a user-defined function to navigate the hiearchy and return the list in table form allowing the hierarchy to be joined within a query. -- -Paul Nielsen, SQL Server MVP SQL Server 2000 Bible, Wiley Press Enterprise Data Architect, www.Compassion.com CREATE -- alter FUNCTION dbo.SubClasses (@ClassName CHAR(25)) RETURNS @Classes TABLE (ClassID INT, ClassName VARCHAR(25), Lv INT) AS BEGIN DECLARE @LC INT SET @LC = 1 -- insert the top level INSERT @Classes SELECT ClassID, ClassName, @LC FROM dbo.Class with (NoLock) WHERE ClassName = @ClassName -- Loop through sub-levels WHILE @@RowCount > 0 BEGIN SET @LC = @LC + 1 -- insert the Class level INSERT @Classes SELECT ClassTree.ClassID, ClassTree.ClassName, @LC FROM dbo.Class ClassNode with (NoLock) JOIN dbo.Class ClassTree with (NoLock) ON ClassNode.ClassID = ClassTree.SuperClassID JOIN @Classes CC ON CC.ClassID = ClassNode.ClassID WHERE CC.Lv = @LC - 1 END RETURN END "Hazz" <hazz (AT) nospameroosonic (DOT) net> wrote in message news:e2nmG%23A2EHA.1076 (AT) TK2MSFTNGP09 (DOT) phx.gbl... What are my options for table/db designs to model an organization chart. Parent/child/siblings root/leaves ideas? How can depth or "layers deep" be handled? I haven't had to think about this for awhile and all of the sudden I have people asking me questions about using queues to simplify hiearchical or binary tree designs to avoid recursive descent parsers. A performance thing I hear. Also I am becoming aware of my own intuitive "adjacency modeling" that looks back into itself. My ID calls your ID in the same table. I think this might be part of the recursive problem I think I want to avoid. I have worked with some pretty nasty database designs in the past where performance got severely compromised. thank you for any ideas or questions to help me thing about this. -greg |
#6
| |||
| |||
|
|
On Wed, 1 Dec 2004 17:37:44 -0800, Hazz wrote: What are my options for table/db designs to model an organization chart. Parent/child/siblings root/leaves ideas? How can depth or "layers deep" be handled? I haven't had to think about this for awhile and all of the sudden I have people asking me questions about using queues to simplify hiearchical or binary tree designs to avoid recursive descent parsers. A performance thing I hear. Also I am becoming aware of my own intuitive "adjacency modeling" that looks back into itself. My ID calls your ID in the same table. I think this might be part of the recursive problem I think I want to avoid. I have worked with some pretty nasty database designs in the past where performance got severely compromised. thank you for any ideas or questions to help me thing about this. -greg Hi Greg, If you want to explore some alternatives, google this groups for posts by Joe Celko containg the words "nested sets model". Best, Hugo -- (Remove _NO_ and _SPAM_ to get my e-mail address) |
#7
| |||
| |||
|
|
Adjacency modeling would suite your requirement. And it would not compromise on performance if you have proper indexes defined on the table. defining hierarchy would be simple, but you have to some extra work on resolving circular references. if you think the order of the siblings is not important, you can go ahead with this approach. to maintain order, there is some extra cost involved. Av. http://dotnetjunkies.com/WebLog/avnrao http://www28.brinkster.com/avdotnet "Hazz" <hazz (AT) nospameroosonic (DOT) net> wrote in message news:e2nmG#A2EHA.1076 (AT) TK2MSFTNGP09 (DOT) phx.gbl... What are my options for table/db designs to model an organization chart. Parent/child/siblings root/leaves ideas? How can depth or "layers deep" be handled? I haven't had to think about this for awhile and all of the sudden I have people asking me questions about using queues to simplify hiearchical or binary tree designs to avoid recursive descent parsers. A performance thing I hear. Also I am becoming aware of my own intuitive "adjacency modeling" that looks back into itself. My ID calls your ID in the same table. I think this might be part of the recursive problem I think I want to avoid. I have worked with some pretty nasty database designs in the past where performance got severely compromised. thank you for any ideas or questions to help me thing about this. -greg |
#8
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |