O'Reilly logo

Joe Celko's SQL for Smarties, 4th Edition by Joe Celko

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

36

Trees and Hierarchies in SQL

I have a separate book (Trees and Hierarchies in SQL, ISBN 978-1558609204) devoted to this topic in great detail, so this will be a very quick discussion of the three major approaches to modeling trees and hierarchies in SQL.

A tree is a special kind of directed graph. Graphs are data structures that are made up of nodes (usually shown as boxes or circles) connected by edges (usually shown as lines with arrowheads). Each edge represents a one-way relationship between the two nodes it connects. In an organizational chart, the nodes are positions that can be filled by employees and each edge is the “reports to” relationship. In a parts explosion (also called a bill of materials), the nodes are assembly units that ...

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