Chapter 4. Nested Sets Model of Hierarchies
Trees are often drawn as “boxes-and-arrows” charts and that graphic tends to lock your mental image of a tree into a graph structure. Another way of representing trees is to show them as nested sets. It is strange that this approach was overlooked for so long among SQL programmers. Many of us are old enough to have used The Art of Computer Programming (Donald Knuth, ISBN 978-0321751041) in college as our textbook and we should remember this representation of trees in a chapter of his book. Younger programmers think of it as “counting tags” in XML, HTML, and other mark-up languages. Mathematical programmers can think of it as parentheses or as, well, nested sets.
Keywords: trees, subtrees, node, root, ...

Get Joe Celko's Trees and Hierarchies in SQL for Smarties, 2nd Edition 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.