What is MongoDB

MongoDB is a NoSQL Database. It is an open-source document-oriented database and written in c++. it is used for a high volume of data storage. It is not a relational database. It has important features like indexing, regular expression, sharding data, etc.

Advantages:-

Schemaless

Scalability

Performance

High Availability

etc.

Note:- Datastore in the MongoDB as a key-value format.

Example:-

employees collection


{
	name:"John",
	age:35,
	department:"Department A"

}

Mongo DB works based on collection and Document

Collection:- Collection is a group of MongoDB documents. It is the equivalent of an RDBMS table but it has not enforced the same structure of the document so it is possible documents have different structures in the collection.

Document:- it is based on key-value pairs and document the same as a row in RDBMS. Documents have a dynamic schema. Dynamic schema means that documents in the same collection do not need to have the same set of fields or structures.

Example:- employees collection
One Document has this structure


{
	name:"John",
	age:35,
	department:"Department A"

}

The second Document has a different structure


{
	name:"John",
	age:35,
	skill:["NodeJS","Angular","MongoDB","MySQL"],
	department:"Department A",


}

compare RDBMS and Mongo DB structure

RDBMS

MongoDB

Table

Collection

Row

Document

Column

Key