Skip to main content

02 MongoDB

MongoDB is a document-oriented database that stores data within:

  • Documents: consist of key-value pairs which are the basic unit of data in MongoDB.
  • Collections contain sets of documents. Databases are made by one or more collections.

Its data model is based on documents structured just like a JSON file, many documents form a collection. Every document must have ad unique id and can have nested documents inside him.

These data model is convenient for many applications (especially web based ones) since unlike relational databases you don’t have to reconstruct business objects from the normalized tables with expensive joins.

This approach gives you the possibility of structuring your data using the granurality which fits best your application needs.

It’s however possible to extablish references between documents, but it doesn’t make much sense to overuse this feature since that would be just like recreating a relational database.