O'Reilly logo

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

Joe Celko's Trees and Hierarchies in SQL for Smarties, 2nd Edition

Book Description

The demand for SQL information and training continues to grow with the need for a database behind every website capable of offering web-based information queries. SQL is the de facto standard for database retrieval, and if you need to access, update, or utilize data in a modern database management system, you will need SQL to do it. The Second Edition of Joe Celko's Trees and Hierarchies in SQL for Smarties covers two new sets of extensions over three entirely new chapters and expounds upon the changes that have occurred in SQL standards since the previous edition's publication. Benefit from mastering the challenging aspects of these database applications in SQL as taught by Joe Celko, one of the most-read SQL authors in the world.

  • Expert advice from a noted SQL authority and award-winning columnist who has given 10 years of service to the ANSI SQL standards committee
  • Teaches scores of advanced techniques that can be used with any product, in any SQL environment
  • Offers graph theory and programming techniques for working around deficiencies and gives insight into real-world challenges

Table of Contents

  1. Cover image
  2. Table of Contents
  3. Front matter
  4. Copyright
  5. Dedication
  6. Introduction
  7. Chapter 1. Graphs, Trees, and Hierarchies
    1. 1.1. Defining Tree and Hierarchies
    2. 1.2. Network Databases
    3. 1.3. Modeling a Graph in a Program
    4. 1.4. The Great Debate
    5. 1.5. Note on Recursion
  8. Chapter 2. Adjacency List Model
    1. 2.1. The Simple Adjacency List Model
    2. 2.2. The Simple Adjacency List Model Is Not Normalized
    3. 2.3. Fixing the Adjacency List Model
    4. 2.4. Navigation in Adjacency List Model
    5. 2.5. Inserting Nodes in the Adjacency List Model
    6. 2.6. Deleting Nodes in the Adjacency List Model
    7. 2.7. Leveled Adjacency List Model
  9. Chapter 3. Path Enumeration Models
    1. 3.1. Finding the Depth of the Tree
    2. 3.2. Searching for Subordinates
    3. 3.3. Searching for Superiors
    4. 3.4. Deleting a Subtree
    5. 3.5. Deleting a Single Node
    6. 3.6. Inserting a New Node
    7. 3.7. Splitting up a Path String
    8. 3.8. Microsoft SQL Server's HIERARCHYID
    9. 3.9. Edge Enumeration Model
    10. 3.10. XPath and XML
  10. Chapter 4. Nested Sets Model of Hierarchies
    1. 4.1. Finding Root and Leaf Nodes
    2. 4.2. Finding Subtrees
    3. 4.3. Finding Levels and Paths in a Tree
    4. 4.4. Functions in the Nested Sets Model
    5. 4.5. Deleting Nodes and Subtrees
    6. 4.6. Closing Gaps in the Tree
    7. 4.7. Summary Functions on Trees
    8. 4.8. Inserting and Updating Trees
    9. 4.9. Converting Nested Sets Model to Adjacency List Model
    10. 4.10. Converting Adjacency List Model to Nested Sets Model
    11. 4.11. Separation of Edges and Nodes
    12. 4.12. Comparing Nodes and Structure
    13. 4.13. Nested Sets Code in Other Languages
  11. Chapter 5. Frequent Insertion Trees
    1. 5.1. The Data Type of (lft, rgt)
    2. 5.2. Computing the Spread to Use
    3. 5.3. Total Reorganization
    4. 5.4. Rational Numbers and Nested Intervals Model
    5. 5.5. Egyptian Fractions
  12. Chapter 6. Linear Version of the Nested Sets Model
    1. 6.1. Insertion and Deletion
    2. 6.2. Finding Paths
    3. 6.3. Finding Levels
    4. 6.4. Cash Register Tape Problem
  13. Chapter 7. Binary Trees
    1. 7.1. Binary Tree Traversals
    2. 7.2. Binary Tree Queries
    3. 7.3. Deletion from a Binary Tree
    4. 7.4. Insertion into a Binary Tree
    5. 7.5. Heaps
    6. 7.6. Binary Tree Representation of Multiway Trees
    7. 7.7. Stern–Brocot Numbers
  14. Chapter 8. Other Models for Trees
    1. 8.1. Adjacency List with Self-References
    2. 8.2. Subordinate Adjacency List
    3. 8.3. Hybrid Models
    4. 8.4. Path Enumeration Using Prime Number Products
  15. Chapter 9. Proprietary Extensions for Trees
    1. 9.1. Oracle Tree Extensions
    2. 9.2. DB2 and the WITH Operator
    3. 9.3. Date's EXPLODE Operator
    4. 9.4. Tillquist and Kuo's Proposals
    5. 9.5. Microsoft Extensions
    6. 9.6. Other Methods
  16. Chapter 10. Hierarchies in Data Modeling
    1. 10.1. Types of Hierarchies
    2. 10.2. Data Definition Language Constraints
  17. Chapter 11. Hierarchical Encoding Schemes
    1. 11.1. ZIP Codes
    2. 11.2. Dewey Decimal Classification
    3. 11.3. Strength and Weaknesses
    4. 11.4. Shop Categories
    5. 11.5. Statistical Tools for Decision Trees
  18. Chapter 12. Graphs in SQL
    1. 12.1. Adjacency List Model Graphs
  19. Chapter 13. Petri Nets
    1. 13.1. Data Definition Language for Petri Nets
  20. Chapter 14. State Transition Graphs
    1. 14.1. The Temporal Side of Changes
  21. Chapter 15. Hierarchical Database Systems (IMS)
    1. 15.1. Types of Databases
    2. 15.2. Database History
    3. 15.3. Sample Hierarchical Database
    4. 15.4. Summary
  22. Index