Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
HierarchyID - to use it or not?
Message
De
08/02/2010 13:14:57
 
 
À
08/02/2010 12:49:41
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Conception bases de données
Versions des environnements
SQL Server:
SQL Server 2008
Divers
Thread ID:
01448131
Message ID:
01448138
Vues:
29
>>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?
>
>(Copy and Paste) :-)))))))))))))
>

You got me :)

>You should check Using hierarchyid Data Types (Database Engine) in BOL to see if it is appropriate type.
>BTW If (and I see that you will) use SQL 2005 or 2008 you may use CTE (Common Table Expression) to get the Hierarchy.
>
>But Naomi is the Master of CTEs :-)))))))))))))))))))))
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform