database 什么类型的 NoSQL 数据库最适合存储分层数据?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4767944/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 08:01:35  来源:igfitidea点击:

What type of NoSQL database is best suited to store hierarchical data?

databasetreenosqlhierarchical-data

提问by deamon

What type of NoSQL database is best suited to store hierarchical data?

什么类型的 NoSQL 数据库最适合存储分层数据?

Say for example I want to store posts of a forum with a tree structure:

比如说我想用树结构存储论坛的帖子:

original post
 + re: original post
 + re: original post
   + re2: original post
     + re3: original post
   + re2: original post

采纳答案by Ripal Barot

This is graph database. Can be used as tree database.

这是图形数据库。可以用作树数据库。

http://neo4j.com/

http://neo4j.com/

回答by orangepips

MongoDB and CouchDB offer solutions, but not built in functionality. See this SO question on representing hierarchy in a relational databaseas most other NoSQL solutions I've seen are similar in this regard; where you have to write your own algorithms for recalculating that information as nodes are added, deleted and moved. Generally speaking you're making a decision between fast read times (e.g. nested set) or fast write times (adjacency list). See aforementioned SO question for more options along these lines - the flat table approachappears most aligned with your question.

MongoDB 和 CouchDB 提供解决方案,但没有内置功能。请参阅有关在关系数据库中表示层次结构的SO 问题,因为我见过的大多数其他 NoSQL 解决方案在这方面都相似;您必须编写自己的算法来在添加、删除和移动节点时重新计算该信息。一般来说,您要在快速读取时间(例如嵌套集)或快速写入时间(邻接列表)之间做出决定。有关这些方面的更多选项,请参阅上述 SO 问题 -平面表方法似乎与您的问题最相符。

One standard that does abstract away these considerations is the Java Content Repository(JCR), both Apache HymanRabbitand JBoss eXoare implementations. Note, behind the scenes both are still doing some sort of algorithmic calculations to maintain hierarchy as described above. In addition, the JCR also handles permissions, file storage, and several other aspects - so it may be overkill for your project.

将这些考虑因素抽象化的一个标准是Java 内容存储库(JCR),Apache HymanRabbitJBoss eXo都是实现。请注意,在幕后,两者仍在进行某种算法计算以维护如上所述的层次结构。此外,JCR 还处理权限、文件存储和其他几个方面 - 所以它对您的项目来说可能有点矫枉过正。

回答by Maxim Gueivandov

What you possibly need is a document-oriented database like MongoDBor CouchDB.

您可能需要的是面向文档的数据库,例如MongoDBCouchDB

See examples of different techniques which allow you to store hierarchical data in MongoDB: http://www.mongodb.org/display/DOCS/Trees+in+MongoDB

查看允许您在 MongoDB 中存储分层数据的不同技术的示例:http: //www.mongodb.org/display/DOCS/Trees+in+MongoDB

回答by qbolec

Faced with the same issue, I decided to create my own (very simple) solution using Lua + Redis https://github.com/qbolec/Redis-Tree/

面对同样的问题,我决定使用 Lua + Redis 创建我自己的(非常简单的)解决方案https://github.com/qbolec/Redis-Tree/

回答by user1234883

Graph databases would probably also solve this problem. If neo4j is not enough for you in terms of scaling, consider Titan, which is based on various storage back-ends including HBase and should scale very well. It is not as mature as neo4j, but it is a very promising project.

图数据库可能也能解决这个问题。如果 neo4j 在扩展方面对你来说还不够,可以考虑Titan,它基于包括 HBase 在内的各种存储后端,应该可以很好地扩展。它不像neo4j那样成熟,但它是一个非常有前途的项目。

回答by lisak

Exist-dbimplemented hierarchical data model for xml persistence

Exist-db为xml持久化实现分层数据模型

回答by hyc

LDAP, obviously. OpenLDAP would make short work of it.

LDAP,显然。OpenLDAP 可以简化它的工作。

回答by pouya

In mathematics, and, more specifically, in graph theory, a tree is an undirected graph in which any two vertices are connected by exactly one path. So any graph dbwill do the job for sure. BTW an ordinary graph like a tree can be simply mapped to any relational or non-relational DB. To store hierarchical data into a relational db take a look at this awesome presentation by Bill Karwin. There are also ORMs with facilities to store trees. For example TypeORMsupports the Adjacency list and Closure table patterns for storing hierarchical structures.

在数学中,更具体地说,在图论中,树是一种无向图,其中任意两个顶点都由一条路径连接。所以任何图形数据库都可以肯定地完成这项工作。顺便说一句,像树这样的普通图可以简单地映射到任何关系或非关系数据库。要将分层数据存储到关系数据库中,请查看Bill Karwin 的精彩演示。还有一些带有存储树木设施的 ORM。例如TypeORM支持用于存储层次结构的邻接表和闭包表模式。

TypeORM is used in TypeScript\Javascript development. Check popular ORMsto find a one supporting trees based on your environment.

TypeORM 用于 TypeScript\Javascript 开发。检查流行的 ORM以根据您的环境找到一种支持树。

The king of Non-relational DBs [IMHO] is Mongodb. Check out it's documentation. to find out how it stores trees. Trees are the most common kind of graphs and they are used everywhere. Any well-established DB solution should have a way to deal with trees.

非关系数据库之王 [恕我直言] 是 Mongodb。查看它的文档。找出它如何存储树木。树是最常见的一种图,它们无处不在。任何完善的数据库解决方案都应该有处理树的方法。

回答by chris topinka

Just spent the weekend at a training course using MUMUPS db as a back-end for a full stack javascript browser application development framework. Great stuff! I'd recommend GT.M distro of MUMPS under GPL. Or try http://sourceforge.net/projects/mumps/?source=recommendedfor vanilla MUMPS. Check out http://robtweed.wordpress.com/for ewd.js js framework and more info on MUMPS.

刚刚在培训课程中度过了一个周末,使用 MUMUPS db 作为全栈 javascript 浏览器应用程序开发框架的后端。好东西!我会推荐 GPL 下 MUMPS 的 GT.M 发行版。或者尝试http://sourceforge.net/projects/mumps/?source=recommendedfor vanilla MUMPS。查看http://robtweed.wordpress.com/了解 ewd.js js 框架和关于 MUMPS 的更多信息。