Hierarchical data structures are often stored in relational databases. This kind of storage is flexible but flat, so the tree structure has to be build with each query. I want to store forum posts as a tree structure, but it should be possible to query efficiently, say for example selecting posts by date or author.
分层数据结构通常存储在关系数据库中。这种存储是灵活但平坦的,因此必须使用每个查询构建树结构。我想将论坛帖子存储为树结构,但应该可以有效查询,例如按日期或作者选择帖子。
I'd like to have an open source database that is accessible from Java.
我想要一个可以从Java访问的开源数据库。
What is the best way to do so? CouchDB? neo4j? ...?
这样做的最佳方法是什么? CouchDB的? Neo4j的? ...?
2 个解决方案
#1
7
When I first encountered this problem, I've found the great article (link).
当我第一次遇到这个问题时,我发现了很棒的文章(链接)。
In tho words: in RDBMS world there are 2 main tree model storage approaches:
换句话说:在RDBMS世界中,有两种主要的树模型存储方法:
- The Adjacency List Model
- 邻接表模型
- The Nested Set Model
- 嵌套集模型
#2
4
Here's a great article on Neo4j. In general, it looks like neo4j is your best option since document databases are still relatively flat and can result in some awkward setup (still doable though).
这是一篇关于Neo4j的精彩文章。一般来说,看起来neo4j是你最好的选择,因为文档数据库仍然相对平坦,并且可能导致一些尴尬的设置(尽管仍然可行)。
Neo4j, being a graph database, should be a solid fit for storing you tree. I've never used it, but given your problem domain, it seems like the best option (at least the one to investigate first).
作为图形数据库的Neo4j应该非常适合存储树。我从来没有使用它,但鉴于你的问题域,它似乎是最好的选择(至少是首先调查的那个)。
As far as what the "best way" is, I think that depends on your implementation and requirements. I think you should write a simple test against a graph database, a document database, an object database and a relational database (or not) and see which one fits the problem that you're trying to solve.
至于“最佳方式”是什么,我认为这取决于您的实施和要求。我认为您应该针对图形数据库,文档数据库,对象数据库和关系数据库(或不是)编写一个简单的测试,并查看哪个适合您要解决的问题。
#1
7
When I first encountered this problem, I've found the great article (link).
当我第一次遇到这个问题时,我发现了很棒的文章(链接)。
In tho words: in RDBMS world there are 2 main tree model storage approaches:
换句话说:在RDBMS世界中,有两种主要的树模型存储方法:
- The Adjacency List Model
- 邻接表模型
- The Nested Set Model
- 嵌套集模型
#2
4
Here's a great article on Neo4j. In general, it looks like neo4j is your best option since document databases are still relatively flat and can result in some awkward setup (still doable though).
这是一篇关于Neo4j的精彩文章。一般来说,看起来neo4j是你最好的选择,因为文档数据库仍然相对平坦,并且可能导致一些尴尬的设置(尽管仍然可行)。
Neo4j, being a graph database, should be a solid fit for storing you tree. I've never used it, but given your problem domain, it seems like the best option (at least the one to investigate first).
作为图形数据库的Neo4j应该非常适合存储树。我从来没有使用它,但鉴于你的问题域,它似乎是最好的选择(至少是首先调查的那个)。
As far as what the "best way" is, I think that depends on your implementation and requirements. I think you should write a simple test against a graph database, a document database, an object database and a relational database (or not) and see which one fits the problem that you're trying to solve.
至于“最佳方式”是什么,我认为这取决于您的实施和要求。我认为您应该针对图形数据库,文档数据库,对象数据库和关系数据库(或不是)编写一个简单的测试,并查看哪个适合您要解决的问题。