A nifty thing we use in our current project is the ltree extension[1]. It allows representing hierarchical relations and making hierarchical queries in a regular flat table structure.
Love LTREE! Used it for domain label hierarchies (multiple roots - an "ontology") for a data science team to be able to train many different models with shared/overlapping label sets (an ensemble of models for various domains). It makes queries to get training data powerful since you can ask for "all descendants of X" or "ancestors of Y where Z".
Nifty indeed -- that may very well invalidate some old knowledge I have about manually representing trees in relational DBs, supported by recursive CTEs...