Databases

Category Hierarchies with Closure Tables

ER Diagrams · made in Skemio

ER diagram of category taxonomy showing categories, category closure with ancestor and descendant foreign keys, and product relationships.
ER diagram of category taxonomy showing categories, category closure with ancestor and descendant foreign keys, and product relationships.

What it shows

  • Adjacency lists require deep recursive joins to fetch child subtrees.
  • Closure tables record all ancestor-descendant combinations explicitly.
  • Subtree lookups become a single indexed O(1) join query.

The takeaway

Trade slightly higher write costs for instant subtree reads using a relational closure table pattern.

More er diagrams