O'Reilly logo

Inside Microsoft® SQL Server® 2008: T-SQL Querying by Lubor Kollar Itzik Ben-Gan Dejan Sarka, and Steve Kass

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Nested Sets

The nested sets solution is one of the most beautiful solutions I’ve seen for modeling trees.

More Info

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 (Morgan-Kaufmann, 2004).

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, the solution is limited to small trees (or forests of small trees). ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required