Skip to main content

Introduction

MongoDB is a NoSQL database that provides high performance, high availability, and easy scalability. It works on the concept of collections and documents, as opposed to the tables and rows found in relational databases. Below are some key aspects of MongoDB:

Key Features:

  1. Document-Oriented: MongoDB stores data in BSON (Binary JSON) format, allowing for more complex data structures like arrays and nested documents.

  2. Schema-less: Unlike relational databases, MongoDB is schema-less, meaning each document in a collection can have different fields.

  3. Horizontal Scalability: MongoDB can be easily scaled across platforms, using sharding for horizontal scalability.

  4. High Availability: It provides high availability with replica sets, which can contain two or more copies of the data.

  5. Rich Query Language: MongoDB supports a rich set of query operations, including aggregations and geospatial queries.

  6. Strong Consistency: MongoDB provides strong consistency with read and write operations, ensuring data reliability.

  7. ACID Transactions: MongoDB supports multi-document ACID transactions as of version 4.0, ensuring data integrity.

Basic Components:

  • Database: Container for collections.
  • Collection: Equivalent to a table in relational databases but without a schema.
  • Document: A record in a MongoDB collection is basically a document.

Data Model:

MongoDB uses a JSON-like format called BSON to store documents. A simple example:

{
"name": "John",
"age": 30,
"address": {
"street": "123 Main St",
"city": "Anytown"
}
}
  • Real-time analytics
  • IoT applications
  • Mobile applications
  • Content Management Systems
  • Catalogs

In further sections we would learn them in more detail

docker setup

The mongodb can be installed and run through dockers seamlessly using below command

docker run --name mongo-db -p 27017:27017 -v /path/to/folder:/data/db  -d mongo:latest