8 ms·
OP would still blow you away by using the Nested set model: https://en.wikipedia.org/wiki/Nested_set_model https://en.wikipedia.org/wiki/Nested_set_model Altho
by dionyziz 13y ago
OP would still blow you away by using the Nested set model:
https://en.wikipedia.org/wiki/Nested_set_model https://en.wikipedia.org/wiki/Nested_set_model
Although if you've been doing this interview for a while, you're bound to have come across someone who mentioned it, so I'm sure you're familiar.
- arethuza 13y agoAnd even better - knowing that quite a few database engines have extensions to help handling hierarchical data and it probably depends on the details as to which is actually better in a particular circumstance.
- nbouscal 13y agoDefinitely. Nested sets have a lot of weaknesses, and any decent modern database will have CTEs so you can just use an adjacency list with a recursive query, or materialize out the closure table.