I'm developing an web application that uses a non-relational database as a backend (django-nonrel + AppEngine). I need to store some hierarchical data (projects/subproject_1/subproject_N/tasks), and I'm wondering which pattern should I use. For now I thought of:
In my case, the depth of nesting for a normal user will not exceed 4-5 levels. Also, on the UI, I would like to have a pagination for the items on the first level, to avoid to load too many items at the first page load.
From what I understand so far, nested sets are great when the hierarchy is used more for displaying. Adjacency lists are great when editing on the tree is done often. In my case I guess I need the displaying more than the editing (when using nested sets, even if the display would work great, the above pagination could complicate things on editing).
Do you have any thoughts and advice, based on your experience with the non-relational databases?
How you store them depends on how you need to query them. For example, if you only need to find the direct children of a parent, an adjacency list model is probably simplest. If you want to enumerate entire subtrees, an ancestor list or nested sets work well - though I would avoid nested sets on App Engine.
If you need transactional integrity over all the objects in a tree - and won't be updating the tree as a whole more often than a few times a second - you should look into App Engine's support for entity groups and ancestors.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With