MongoDB is an open source database management system (DBMS) that uses a document-oriented data model. It is considered a NoSQL database, as it doesn't use the relational model, and therefore doesn't use SQL as its query language.
The document-oriented model enables MongoDB to store semi-structured data which doesn't require a fixed schema. It can achieve this through the use of JSON documents.
MongoDB is used by some of the largest companies in the world, including Facebook, Google, Nokia, MTV Networks, Cisco, Forbes, and many more.
MongoDB is also a cross platform DBMS, currently supporting Windows, Mac, Solaris, and various Linux distributions at the time of writing.
A MongoDB database is different to a relational database in that, MongoDB uses a document-oriented model to store data. In the document-oriented model, data is stored within documents of a collection. In the relational model, data is stored within rows of a table.
In MongoDB, a collection is a group of documents. A collection typically contains documents that have a similar topic (like Users, Products, Posts, etc).
Collections are therefore, in many ways, similar to tables from the relational model.
Here's an example of a JSON document. This is what documents inside a MongoDB database look like.
_id field is the unique identifier for a document. MongoDB allows for each document to be retrieved/referenced using this field. You can supply this or let MongoDB generate it.
Behind the scenes, MongoDB actually stores the JSON documents in a binary-encoded format called BSON. BSON extends JSON through supporting additional data types and to be efficient for encoding and decoding within different languages.
Each JSON document in a collection can contain its own structure. Therefore, there is no fixed schema that limits the type of data that can be entered into a MongoDB database.
This is in contrast to a relational database where, you must create the schema first (i.e. define the tables, columns, data types, etc), before entering any data. If data doesn't adhere to the schema, it doesn't go into the database.
In a MongoDB database, there is no rule to say which fields, or how many fields, each document should have. For example, one document from a collection might contain name, address, and phone number, while another document might contain name and email address.