Inside Microsoft® SQL Server® 2008: T-SQL Querying
by Lubor Kollar Itzik Ben-Gan Dejan Sarka, and Steve Kass
Conclusion
This chapter covered the treatment of graphs, trees, and hierarchies. I presented iterative/recursive solutions for graphs and also solutions in which you materialize information describing a tree. The main advantage of the iterative/recursive solutions is that you don’t need to materialize and maintain any additional attributes—the graph manipulation is based on the stored edge attributes. The materialized path solution materializes an enumerated path and possibly also the level for each node in the tree. You can either maintain your own custom materialized path or use SQL Server 2008’s built-in HIERARCHYID data type. In the materialized path solution, the maintenance of the additional information is not very expensive, and you benefit ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access