I am challenged with persisting a structure that is inherently tree-like:
- a drawing can have multiple layers
- a layer can have multiple lines
- a line can have multiple points
My current implementation is with MongoDB, points as an Array attribute of lines and the rest handled with has_many
associations.
I read http://docs.mongodb.org/manual/tutorial/model-tree-structures where a better approach is explained, and I'm probably going to upgrade to that, if it is the best avenue.
The biggest impact on DB is when I want to change a drawing, keeping the previous version: I'm deep copying the entire tree, to prevent side effects. I know, I could go with of copy-on-write, but I still have to figure it out.
I want to know if there is any better approach/DB I could use for managing tree structures.
In my opinion:
- I cannot use RDBMS because of the number of joins involved (monstrous)
- Neo4J is overkill
- having everything inside a single Mongo document is hard to manage and could potentially go over the 16MB max size limit
What's your experience with trees?