1 / 16

Hierarchies Evan Koch Senior Architect ekoch@askcts.com

Hierarchies Evan Koch Senior Architect ekoch@askcts.com. Agenda. Traditional Approach Nested Sets Approach HierarchyID Approach Questions. Traditional Approach - Model. Larry. Matt. David. Mark. Melinda. Jennifer. Craig. Tom. Wendy. Sample Org Chart.

season
Download Presentation

Hierarchies Evan Koch Senior Architect ekoch@askcts.com

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. HierarchiesEvan KochSenior Architectekoch@askcts.com

  2. Agenda • Traditional Approach • Nested Sets Approach • HierarchyID Approach • Questions

  3. Traditional Approach - Model Larry Matt David Mark Melinda Jennifer Craig Tom Wendy Sample Org Chart

  4. Traditional Approach - Table

  5. Nested Sets Approach - Model David Melinda Matt Mark Jennifer Craig Tom Wendy Larry

  6. Nested Sets Approach - Model 1 Larry 18 Matt 8 David Mark 17 2 7 11 12 9 Melinda Jennifer 16 13 3 Craig 4 5 Tom 6 10 14 Wendy 15 Sample Org Chart

  7. Nested Sets Approach - Model David 8 Melinda 9 10 11 Matt Mark Jennifer Craig Tom 1 2 3 4 5 6 7 Wendy 12 13 16 14 15 17 18 Larry

  8. Nested Sets Approach - Table Table Schema

  9. Nested Sets Approach - Table

  10. HierarchyIDApproach - Model Larry / Matt /1/ David /2/ Mark /3/ Melinda /2/1/ Jennifer /3/1/ Craig /1/1/ Tom /1/2/ Wendy /3/1/1/ Sample Org Chart

  11. HierarchyIDApproach - Model David /2/ Melinda /2/1/ Matt /1/ Mark/3/ Jennifer /3/1/ Craig /1/1/ Tom /1/2/ Wendy /3/1/1/ Larry /

  12. HierarchyIDApproach - Table Table Schema

  13. HierarchyID Approach - Table

  14. HierarchyID Functions • GetAncestor • GetDescendant • GetLevel • GetRoot • IsDescendantOf • Parse • GetReparentedValue • ToString • Read * • Write *

  15. Queries • Retrieve a subtree given the root • Find all leaf nodes • Retrieve a single path • Find immediate subordinates • Find immediate peers

  16. References Joe Celko’s SQL For Smarties – Advanced SQL Programming http://www.amazon.com/Joe-Celkos-SQL-Smarties-Fourth/dp/0123820227/ref=sr_1_1?s=books&ie=UTF8&qid=1342876431&sr=1-1&keywords=sql+for+smarties

More Related