3 ms·
Depending the DB, some databases have build-in support for HierarchyId or ParentId ( eg. SQL server : https://docs.microsoft.com/en-us/sql/relational-databases/
by NicoJuicy 7y ago
Depending the DB, some databases have build-in support for HierarchyId or ParentId ( eg. SQL server : https://docs.microsoft.com/en-us/sql/relational-databases/tables/tutorial-using-the-hierarchyid-data-type?view=sql-server-2017 https://docs.microsoft.com/en-us/sql/relational-databases/ta... )
Otherwise nested sets of closure tables are popular db patterns.
I love the trick of nested sets though. Calculating a number for each side of a type do your RightBower and LeftBower can be used ( https://images.app.goo.gl/Bv2wiC3gG6DW869r5 https://images.app.goo.gl/Bv2wiC3gG6DW869r5 )