MongoDB
MongoDB is a document-oriented database. It contains collections of documents. Each document is a JSON-like object:
{ _id: ObjectId("558e846730044ede70743be9"), name: "Gandalf", age: 2000, pseudonyms: [ "Mithrandir", "Olorin", "Greyhame" ], possessions: [ { name: "Glamdring", type: "sword" }, { name: "Narya", type: "ring" } ] }
Just as in JSON, a document is a set of key-value pairs, where the values can be strings, numbers, Booleans, dates, arrays, or subdocuments. Documents are grouped in collections, and collections are grouped in databases.
You might be thinking that this is not very different from SQL: a document is similar to a row and a collection corresponds to a table. There are two important differences:
The values in documents can be simple values, arrays, subdocuments, or arrays of subdocuments. This lets us encode one-to-many and many-to-many relationships in a single collection. For instance, consider the wizard collection. In SQL...