Hierarchical Data – Adjacency Lists and Nested Set Models

Topics covered
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


Data Structures - (some) Trees
Answers 383 questions95. Data Structures – Arrays and Array-ish
Answers 383 questions

Data Structures - Heaps and Tries
Answers 383 questions94. Data Structures - Primitives
Answers 383 questions

Data Structures - Arrays and Array-ish
Answers 383 questionsDesigning Data-Intensive Applications – Scalability
Answers 383 questions

Designing Data-Intensive Applications - SSTables and LSM-Trees
Answers 383 questionsGraph Algorithms
Answers 383 questionsAll Your Database Are Belong to Us
Answers 383 questionsDesigning Data-Intensive Applications – Data Models: Query Languages
Answers 383 questions

Strategic Design and Domain Events
Answers 383 questions

Designing Data-Intensive Applications – Multi-Leader Replication
Answers 383 questionsDesign Patterns Part 3
Answers 383 questionsUnderstanding Complexity Theory
Answers 383 questions

Designing Data-Intensive Applications - Data Models: Relational vs Document
Answers 383 questions
