4 ms·
For modelling trees, I much prefer using a list of ancestors compared to the parent-child adjacency list because it doesn't require recursion to answer basic qu
by bokwoon 5y ago
For modelling trees, I much prefer using a list of ancestors compared to the parent-child adjacency list because it doesn't require recursion to answer basic questions. I had thought about how I would model threaded comments in SQL some time ago and wrote down an example of what I mean:
https://gist.github.com/bokwoon95/4fd34a78e72b2935e78ec0f40e7e49e1 https://gist.github.com/bokwoon95/4fd34a78e72b2935e78ec0f40e...
- gavinray 5y agoThis data structure you used is covered by the native postgres data type "ltree" right? https://www.postgresql.org/docs/current/ltree.html https://www.postgresql.org/docs/current/ltree.html "This module implements a data type ltree for representing labels of data stored in a hierarchical tree-like structure. Extensive facilities for searching through label trees are provided."