Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
HierarchyID - to use it or not?
Message
From
08/02/2010 12:45:03
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
Database design
Title:
HierarchyID - to use it or not?
Environment versions
SQL Server:
SQL Server 2008
Miscellaneous
Thread ID:
01448131
Message ID:
01448131
Views:
154
I need to model an Agent structure where an Agent reports to a superior who can report to a superior and so on ad infinitum.

I have recently discovered the HierarchyID type in SQL Server and would like to know how exactly I need to create the table.

I have an AgentPK field of type uniqueidentifier. Now I need the Hierarchy, do I just create a field like HieararchyPath type HierarchyID? I get the impression from what I have found on-line that the hierarchyid field holds the path of all superiors' primary keys, so is a uniqueidentifier appropriate to use as the table's Primary Key? Or does it not matter?

Is using the hierarchyid the best way to do this, or do I go with the old ReportsTo field where I store the superior's Primary Key in this field?
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Next
Reply
Map
View

Click here to load this message in the networking platform