Nested sets
The nested sets solution is one of the most beautiful solutions I’ve seen for modeling trees.
More Info
Joe Celko has extensive coverage of the nested sets model in his writings. You can find Joe Celko’s coverage of nested sets in his book Joe Celko’s Trees and Hierarchies in SQL for Smarties, Second Edition (Morgan Kaufmann, 2012).
The main advantages of the nested sets solution are simple and fast queries, which I’ll describe later, and no level limit. Unfortunately, however, with large data sets the solution’s practicality is usually limited to static trees. For dynamic environments that incur frequent changes, the solution ...
Get 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.