MongoDB is a NoSQL Database. It is an open-source document-oriented database 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.
Key Features:
1. Document-Oriented: Data is stored in collections of documents (similar to rows in a table), which can have various fields and structures.
2 Flexible Schema: MongoDB allows documents to have different structures, meaning fields can be added or removed dynamically.
3. Scalability: MongoDB is designed for horizontal scalability, meaning you can distribute your data across multiple servers easily.
4. High Performance: It’s optimized for high write and read throughput, making it suitable for real-time applications.
5. Indexing and Aggregation: MongoDB supports indexing, allowing for fast querying, and has powerful aggregation features for data processing.
6. Replication and Sharding: It provides features like replication for high availability and sharding for distributing data across multiple machines.
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
MongoDB
Table
Row
Column