Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MongoDB: How to represent a schema diagram in a thesis?

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: Possible Diagram?

like image 258
Andrew Avatar asked Jul 04 '12 06:07

Andrew


People also ask

How do you explain a schema diagram?

A schema diagram is a diagram which contains entities and the attributes that will define that schema. A schema diagram only shows us the database design. It does not show the actual data of the database. Schema can be a single table or it can have more than one table which is related.

Can we draw ERD for MongoDB?

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.


1 Answers

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.

UML intro from IBM site

like image 96
Prasith Govin Avatar answered Oct 03 '22 11:10

Prasith Govin