What is MongoDB
What is NoSQL?
NoSQL is a kind of database that, unlike most relational databases, does not provide a SQL interface to manipulate data. NoSQL databases usually organize the data in a different way other than tables.
NoSQL databases are divided into three categories: column-oriented, key-value pairs, and document-oriented databases. This article focus document-oriented databases, as it seems to be best solution for many Web sites.
SQL based relational databases do not scale well when they are distributed over multiple cluster nodes. Data partition is not an easy to implement solution when the applications use join queries and transactions.
NoSQL databases are not new. Actually, there were key-value pair based databases before relational database became popular.
What is a document-oriented database?
For document-oriented databases, a document is a data structure that has variable number of properties. Each property has a value that can be scalar (number, string, etc.) or a vector (arrays or objects).
You can see a document as an object or associative array like in PHP. To understand better this concept, here is the definition of a “person” document:
MongoDB is a very interesting document-oriented database implementation for several reasons:
- It uses JSON, instead of XML
- It is fast, as it is written in C++
- Supports index definitions
- Provides an easy to use query interface, very similar to some database abstraction layers
- Supports operations with sub-documents
- Provides a native PHP extension
- Supports auto-sharding
- Supports map-reduce for data transformation