Oh no.. Document Model? Why couldn't you say JSON from the beginning?
I don’t know if you’re familiar with the term “Document Model” or not, but I’m sure that most of you already know what JSON is.
For those who missed it: JSON is a format for writing data objects in text. The acronym itself stands for JavaScript Object Notation. You can find more information about the JSON format here.
I know I’m not an expert on data models, but I found comfort as a causal developer in using JSON, and afterwards with the Document Model provided by MongoDB , given that the differences between them are not easy to spot for the untrained eye :), especially when talking about readability of the object data, compared to the long traditional relational model. Using key-value pairs to represent data is always easier, both to read and to maintain data, than other models.
Moreover, if we want to scale up the object that contains the data, the task is easier using the Document Model: All we need to do is to add the new properties as key-value pairs to the current object. Meanwhile, changes to the object structure in the relational model is rather rigid and changing it might cause the application based on it to break.
Here is an example of a document:
{_id: 10223047894, name: “Ahmad Hosny”, task: “Write some code”}
It contains a simple object: the first field is the mandatory, unique “_id” field, the second is the textual “name” field and the third is the also textual “task” field. Simple, right?
Well, I’d like to talk more about it but it’s better to read from the specialists :) Have a look at MongoDB’s introduction to data modeling and for more examples see this page.