A brief introduction to MongoDB
MongoDB is a non-relational database manager which stores records as JSON objects. MongoDB is also known as Document Oriented DB. All official documents can be found in MongoDB official page.
This feature gives the following advantages:
- Embedded documents (one record can have an array as one of their fields or properties). This have the advantage that you can save doing huge JOINS.
- The DB schema is polymorph or dynamic. What does this mean? This means that a DB record must have different number of fields that another record, although they correspond with the same entity. This is also known as “schema-less”.
- The documents are grouped into collections and, as the documents they contain are polymorph, they don’t have a rigid structure and allow any kind of documents (well, not any kind, but we’ll see later). The mongodb collection/document/field corresponds to table/row/column in another DB systems.
The applications communicate with MongoDB through Drivers. This drivers are the way MongoDB communicate with the main languages used on the web world. There are several drivers available for the main web application environments, and can be found in the official drivers page.
Example of document
Lets see an example of DB modeling with MongoDB. We need to store the information about our web application users. We may do this design:
street: "123 Long Road Street",
city: "New Town",
In this example, you can see the embedded data in a typical MongoDB structure.
In other posts I will go deep in the MongoDB basics.