Implementing a hierarchical data structure in a database

There are more options than just the two you mention. There are:

  • Adjacency List (the “parent_id” one almost everyone uses)
  • Nested Sets
  • Path Enumeration
  • Closure Table (aka Adjacency Relation)

See my answer to “What is the most efficient/elegant way to parse a flat table into a tree?

Or a couple of books:

Leave a Comment