News for hackers. Stuff that matters.
Re:Ask HN: Best practices for modeling B-Trees in SQL? by krapp on Wednesday April 28, 2021 @03:41PM (#26973247)
What you're describing (id and parent id, sometimes also root id) is known as the relational model.

There is also the nested set model described here[0,1].

[0]http://mikehillyer.com/articles/managing-hierarchical-data-i...

[1]https://coderwall.com/p/ohomlg/nested-set-model-the-best-app...

The relational model is much easier to implement (HN and most forums use it), and insertions are faster, but building an entire tree from any point but the root requires recursion. Nested sets are more difficult to implement and inserts and updates are more complex due to tree balancing, but getting the actual trees is simple at any level.

Re:Ask HN: Best practices for modeling B-Trees in SQL? by JoHawth31 on Wednesday April 28, 2021 @08:10PM (#26975823)
Thank you so much krapp!