Scenarios

Throughout the chapter, I will use three scenarios: Employee Organizational Chart (tree, hierarchy), Bill Of Materials or BOM (DAG), and Road System (undirected cyclic graph). Note what distinguishes a (directed) tree from a DAG. All trees are DAGs, but not all DAGs are trees. In a tree, an item can have at most one parent; in some management hierarchies, an employee can have more than one manager.

Employee Organizational Chart

The employee organizational chart that I will use is depicted graphically in Figure 9-2.

Employee Organizational Chart

Figure 9-2. Employee Organizational Chart

To create the Employees table and populate it with sample data, run the code in Example 9-1 ...

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.