Conclusion

This chapter covered the treatment of graphs, trees, and hierarchies. I presented iterative/recursive solutions for graphs, and also solutions where 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; rather, 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. The maintenance of the additional information is not very expensive, and you benefit from simple and fast set-based queries. The nested sets solution materializes left and right values representing set containment relationships, ...

Get Inside Microsoft® SQL Server™ 2005: T-SQL Querying now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.