I am currently writing a thesis and need to display the schema of my MongoDB in a diagram. I have found no resources about diagrams for document-based databases.
There are Entity Relationship Diagrams (ERD) for relational databases. What options do I have for MongoDB? I've noticed that a lot of blogs just display the raw JSON as their "diagram" but this isn't feasible in my thesis.
Here is a sample of one of my JSON structures:
//MultiChoiceQuestion
{
"title": "How are you?",
"valid_answers" : [
{
"_id" : ObjectID(xxxx),
"title": "Great",
"isCorrect": true,
},
{
"_id" : ObjectID(yyyy),
"title": "OK",
"isCorrect": false,
},
{
"_id" : ObjectID(zzzz),
"title": "Bad",
"isCorrect": false,
}
],
"user_responses" : [
{
"user": ObjectID(aaaa),
"answer": ObjectID(xxxx)
},
{
"user": ObjectID(bbbb),
"answer": ObjectID(xxxx)
},
{
"user": ObjectID(cccc),
"answer": ObjectID(yyyy)
}
]
}
//User
{
"_id": ObjectID(aaaa),
"name": "Person A"
}
//User
{
"_id": ObjectID(bbbb),
"name": "Person B"
}
//User
{
"_id": ObjectID(cccc),
"name": "Person C"
}
Could this be a possible diagram:
We found class diagrams to actually be one of the best ways to represent a mongo schema design.
It can capture most of the items that a document will have such as arrays, embedded objects and even references.
General guidelines we use to relate onto concepts to uml
Embed = Composition aggregation
Reference = Association class
If you're unfamiliar with the uml terminology then this is a decent intro.