Overview - Adjacency list pattern
What is it?
The adjacency list pattern is a way to represent hierarchical data, like trees or graphs, inside a database. Each item stores a reference to its parent, creating a chain of connections. This pattern helps organize data with parent-child relationships, such as categories or organizational charts. It is simple and works well for many use cases.
Why it matters
Without a way to represent hierarchies, databases would struggle to model real-world relationships like company structures or folder trees. The adjacency list pattern solves this by linking items through parent references, making it easy to find related data. Without it, applications would need complex workarounds, slowing down development and making data harder to understand.
Where it fits
Before learning this, you should understand basic database tables and how to store simple records. After this, you can explore other hierarchical patterns like materialized paths or nested sets, which optimize querying. This pattern is a foundation for working with trees and graphs in databases.