Published Jun 8, 2015

Hierarchical Data – Adjacency Lists and Nested Set Models

    Dive into the world of hierarchical data with Coding Blocks, as they unravel the intricacies of adjacency lists and the Nested Set Model while offering performance tips and exploring the utility of Recursive Common Table Expressions (CTEs) for managing complex datasets.
    Episode Highlights
    Coding Blocks logo

    Popular Clips

    Episode Highlights

    • Introduction

      The hosts introduce hierarchical datasets, starting with adjacency lists. Alan Underwood explains that an adjacency list is a simple self-referencing parent-child relationship within the same table, commonly seen in databases. Michael Outlaw simplifies it further by stating, "Every record knows its immediate parent." They use an employee table as an example to illustrate how each employee's manager is identified by a manager ID 1.

         

      Implementation

      The discussion highlights the ease of implementing adjacency lists, especially with RDBMS that support CTEs. However, Michael points out that large trees can cause performance issues due to the recursive nature of queries. Alan adds, "If you have a really deep tree and a wide table, these queries get expensive." They also mention that frequent querying can further exacerbate these issues 2.

         

      Practical Use

      The hosts share practical insights and examples of using adjacency lists in real-world scenarios. Alan mentions a popular blog post on product hierarchies and categories, emphasizing the model's relevance. They also discuss the importance of laying groundwork for understanding different hierarchical data models in future episodes 3 4.

    Related Episodes