2 ms·
This reminds me of the MPTT (Modified Pre-order Tree Traversal) method used in a lot of older SQL-based software, like phpBB (and no doubt still used today.) I
by jchw 3y ago
This reminds me of the MPTT (Modified Pre-order Tree Traversal) method used in a lot of older SQL-based software, like phpBB (and no doubt still used today.) I won't attempt to explain exactly how it works, but it stores a tree structure in a way that makes many kinds of queries possible even when treating the table more or less like a flat list. It was very useful for being able to snag subtrees in relatively simple SQL queries.
Also, tangentially, I am reminded of the array representation of the binary heap structure. An array-based binary heap maintains (as far as I am aware) the same properties as a pointer-based binary heap, but the structure is entirely implicit based on index.
There's a lot of ways to skin a cat for sure. Reaching for pointer-based trees of objects is of course totally fine, but there's a lot of ways to normalize data, and if you have a decent idea of what you're looking for you can definitely save a lot of trouble.