leojg
leojg

Reputation: 1186

Best DB for represent a tree structure

Which is the best DB for a tree strucutre?

I have different kinds of objects which can have parent or child objects . The structure of this objects is dinamic, ej: some can have a 'name' field while others dont, some can have a 'menu' field and others an 'image' field.

One element can have 1000 fields(or attributes) while other can have just 1.

An SQL database is discarted, because it can not be schemaless

Currently, I am storing this in mongoDB, but I think it is not the most appropiate thing, because I can not have infinite childs or parents on one document(its limited to 16mb) so I have to make a separate document for every object and then one of the greatest advantaje of mongodb is lost.

Another solution migth be a graph db, im not familiar with them, but they seem the perfect solution, a tree is a graph after all.

So what do you think?

Upvotes: 1

Views: 903

Answers (2)

stephen mallette
stephen mallette

Reputation: 46206

A graph database sounds like the right answer. Please consider looking at TinkerPop which is an open source graph technology stack. It enables connection to most any graph database (Neo4j, Titan, OrientDB, Bitsy, etc.) in an agnostic way. Obviously, that enables you to try out different graph implementations to find the right one for you.

While far from being performant, compared to true graph databases, there's even a MongoDB implementation of a graph. I'd recommend starting with a simple in-memory TinkerGraph and a Gremlin REPL to begin your learning process.

Upvotes: 3

RickyA
RickyA

Reputation: 16029

Take a look at the graph databases. Neo4j is leading here.

Upvotes: 0

Related Questions