Hoverbear Consulting

A computer scientist working in open source towards a more hopeful future.


Hierarchical Structures in PostgreSQL

Modelling hierarchical/team/categorical/tag data with arbitrary depths.

It's a common pattern: a database developer at a startup is probably on the Product subteam of the Engineering team at their company. In a department store, shoes are a subcategory of clothing, while your favorite thermos is probably in the travel department.

In any Github organization, there are teams within teams within teams. In any large department store there are categories deeply nested. In any recipe book, there are many ways to classify food.

So how can we model them?