Equivalent of ERD for MongoDB?

MongodbErdNosql

Mongodb Problem Overview


What would be the equivalent of ERD for a NoSQL database such as MongoDB?

Mongodb Solutions


Solution 1 - Mongodb

It looks like you asked a similar question on Quora.

As mentioned there, the ERD is simply a mapping of the data you intend to store and the relations amongst that data.

You can still make an ERD with MongoDB as you still want to track the data and the relations. The big difference is that MongoDB has no joins, so when you translate the ERD into an actual schema you'll have to make some specific decisions about implement the relationships.

In particular, you'll need to make the "embed vs. reference" decision when deciding how this data will actually be stored. Relations are still allowed, just not enforced. Many of the wrappers for MongoDB actually provide lookups across collections to abstract some of this complexity.

Even though MongoDB does not enforce a schema, it's not recommended to proceed completely at random. Modeling the data you expect to have in the system is still a really good idea and that's what the ERD provides you.

So I guess the equivalent to the ERD is the ERD?

Solution 2 - Mongodb

You could just use a UML class diagram instead too.

Solution 3 - Mongodb

I know of no standard means of diagramming document-oriented "schema".

I'm sure you could use an ERD to map out your schemata but since document databases do not truly support--or more importantly enforce--relationships between data, it would only be as useful as your code was disciplined to internally enforce such relationships.

Solution 4 - Mongodb

I have been thinking about the same issue for quite some time. And I came to the following conclusion: If NoSQL databases are generally schemaless, you don't actually have a 'schema' to illustrate in a diagram.

Thus, I think you should take a "by example" approach. You could draw some mindmaps exemplifying how your data would look like when stored in a NoSQL DB such as MongoDB.

And since these databases are very dynamic you could also create some derived mindmaps to show how the data from today could evolve in time.

Take a look at this topic too.

https://stackoverflow.com/questions/13429306/confusion-about-nosql-design

Solution 5 - Mongodb

Moon Modeler supports schema design for MongoDB. It allows users to define diagrams with nested structures.

Solution 6 - Mongodb

MongoDB does support 'joins', just not in the SQL sense of INNER JOIN (the default SQL join). While the concept of 'join' is typically associated with SQL, MongoDB does have the aggregation framework with its data processing pipeline stages. The $lookup pipeline stage is used to create the equivalent of a LEFT JOIN in SQL. That is, all documents on the left of a relationship will be pass through the pipeline, as well as any relating documents on the right side of the relationship. The documents are modified to include the relationship as part of the new documents.

Consequently, I postulate that Entity Relationship Diagrams do have a role in MongoDB. Documents are certainly related to each other in the db, and we should have a visualization of these relationships, including the cardinality relationship, e.g. full participation, partial participation, weak/strong entities, etc.

Of course, MongoDB also introduces the concept of embedded documents and referenced documents, and so I argue it adds additional flavor to the model of the ERD. And I certainly would want to see embedded and referenced relationships mapped out in a visual diagram.

The remaining question is so what is out there? What is out there for Mongoose for NodeJS? Mongoid for Ruby? etc. If you check the respective repositories for their corresponding ORMs (Object Relational Mappers), then you will see there are ERDs for them. But in terms of their completeness, perhaps there is a lot to be desired and the open source community is welcome to make contributions.

> https://www.npmjs.com/package/mongoose-erd > > https://rubygems.org/gems/railroady

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionCatalin BraescuView Question on Stackoverflow
Solution 1 - MongodbGates VPView Answer on Stackoverflow
Solution 2 - MongodbsinhaView Answer on Stackoverflow
Solution 3 - MongodbRob RaischView Answer on Stackoverflow
Solution 4 - MongodbGabriel CView Answer on Stackoverflow
Solution 5 - MongodbVaclavView Answer on Stackoverflow
Solution 6 - MongodbDaniel ViglioneView Answer on Stackoverflow