Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

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 
like image 843
deamon Avatar asked Jan 22 '11 13:01

deamon


People also ask

Which type of database is best for hierarchical data storage?

Document based database like MongoDB, and Redis are great for small scale, hierarchical data with a relatively small amount of children for each entry.

Is NoSQL a hierarchical database?

Though it is possible to store hierarchical data via SQL databases, it isn't generally desirable to do so. NoSQL databases, on the other hand, make up for an excellent option for storing data in a hierarchical database model.

Which is the best way to store hierarchical information?

The standard method of storing hierarchical data is simple parent-child relationship. Each record in the database includes a —parent id—, and a recursive query through the records build the children, siblings, and levels of the tree.


1 Answers

MongoDB and CouchDB offer solutions, but not built in functionality. See this SO question on representing hierarchy in a relational database as 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 approach appears most aligned with your question.

One standard that does abstract away these considerations is the Java Content Repository (JCR), both Apache JackRabbit and JBoss eXo are 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.

like image 86
orangepips Avatar answered Oct 16 '22 01:10

orangepips