建议在非关系数据库中使用分层数据? [英] Recommendations with hierarchical data on non-relational databases?

查看:137
本文介绍了建议在非关系数据库中使用分层数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个使用非关系数据库作为后端的Web应用程序(django-nonrel + AppEngine)。
我需要存储一些分层数据(项目/子项目_1 /子项目_N /任务),我想知道应该使用哪种模式。现在我想到了:


  • 邻接列表(存储项目的父ID)
  • 嵌套集(存储项目的左右值)


    在我的情况下,普通用户的嵌套深度不会超过4- 5个级别。
    另外,在用户界面上,我希望为第一级的项目分页,以避免在第一次加载页面时加载太多项目。



    从目前我的理解来看,当层次结构更多地用于显示时,嵌套集很棒。当在树上进行编辑经常完成时,邻接列表非常棒。在我的情况下,我想我需要的显示比编辑更多(当使用嵌套设置时,即使显示效果很好,上面的分页可能会使编辑变得复杂)。



    你有任何想法和建议,根据你对非关系数据库的经验吗? 解决方案

取决于你如何查询它们。例如,如果您只需要查找父项的直接子项,则邻接列表模型可能是最简单的。如果你想枚举整个子树,祖先列表或嵌套集合运行良好 - 尽管我会避免在App Engine上嵌套集合。



如果您需要事务完整性树中的对象 - 并且不会每秒更新一次,而是每秒更新一次 - 您应该查看App Engine对实体组和祖先的支持。


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:

  • Adjacency List (store the item's parent id)
  • Nested sets (store left and right values for the item)

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.

这篇关于建议在非关系数据库中使用分层数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆