MongoDB is one of the most popular and powerful No SQL databases available today. As an open-source document-oriented database, it has revolutionized the way data is stored and managed. In this blog series, we aim to provide a thorough introduction to MongoDB, exploring its architecture and how it works.

Key Contents

  • What is MongoDB?
  • History & Versions
  • Environments
  • Architecture
  • What it Contains?

What is MongoDB?

MongoDB is an open-source, document-based database designed to store large volumes of data efficiently. Unlike traditional relational databases that store data in tables, MongoDB uses a flexible, schema-less design that stores data in JSON-like documents

History & Versions

History

MongoDB was developed in 2007 by the company 10Gen (now MongoDB Inc.), founded by Dwight Merriman, Eliot Horowitz, and Kevin P. Ryan. The name “MongoDB” is derived from “humongous,” signifying its ability to handle vast amounts of data.

Versions

  • MongoDB 1.0 – February 2009
  • MongoDB 2.0 – September 2011
  • MongoDB 3.0 – March 2015
  • MongoDB 4.0 – June 2018
  • MongoDB 5.0 – July 2021
  • MongoDB 6.0 – July 2022
  • MongoDB 7.3 – July 2024

Environments

  • MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud.
  • MongoDB Enterprise: The subscription-based, self-managed version of MongoDB.
  • MongoDB Community: Free to use, source-available edition.

Key differences between MongoDB and RDBMS

MongoDB RDBMS
Non-relational and document-oriented databaseRelational database
Suitable for hierarchical data storageNot suitable for hierarchical data storage
Individual records are stored as documentsIndividual records are stored as rows in tables
Uses MongoDB Query Language (MQL)Uses Structured Query Language (SQL)
Has a dynamic schemaHas a predefined schema
Centers around the CAP theoremCenters around ACID properties
Does not support Foreign KeysSupports the usage of Foreign Keys
Does not support JOIN operationsSupports JOIN operations
Typically faster than RDBMS for large datasetsTypically slower than MongoDB for large datasets
Scales horizontally (easier to distribute data)Scales vertically (adding more power to existing hardware)
Schema-less, making it flexible for various data typesSchema-bound, requiring predefined data structures
Supports replication and sharding for high availability and scalabilityPrimarily supports replication; sharding can be complex
Table 1: MongoDB Vs RDBMS

Architecture

MongoDB’s architecture is designed for high performance, high availability, and easy scalability. The architecture consists of the following components:

Applications:

Applications interact with MongoDB using drivers, which enable communication with the database.

Security:

MongoDB provides robust security features including authentication, authorization, encryption, auditing, and hardening.

  • Authentication: It is the process of validating the identity of an entity attempting to establish a connection.
  • Authorization: It is the process of determining the specific  permissions of the entity attempting to connect.
  • Encryption: Protects data at rest and in transit.
  • Auditing: It logs access and actions executed against the database and captures administrative actions, including schema operations ,authorization,read and write operations and authentication.
  • Hardening: Ensures only trusted hosts can access the database.

Drivers:

Client libraries for different programming languages (Java, Python, .NET, Node.js, etc.), handling the conversion of data between BSON (binary JSON) and application formats.

Query Engine:

Processes queries through stages like parsing, planning, and optimization.

  • Query Parsing: It Converts queries into a standard format.
  • Query Planning: The query planner generates multiple execution plans to determine the best way to execute the query.
  • Query Optimization: It evaluates the generated plan from the query planner to select the most efficient one. 

MongoDB Data Model:

Manages how queries are executed, data is retrieved, and operations like filtering and sorting are performed.

Storage Engine:

Manages how data is stored in memory and on disk.MongoDB supports different storage engine

MMAPv1: A traditional storage engine based on memory-mapped files. It offers high performance for read operations but has limitations with write operations and does not support compression.

Wired Tiger: The default storage engine from MongoDB 3.0 onwards. It offers document-level concurrency, compression, and encryption at rest. It provides better performance and efficiency compared to MMAPv1.

In Memory: Stores data in memory without persisting it to disk, providing faster read and write operations. Suitable for scenarios where data persistence is not required.

What it Contains?

In MongoDB, data is stored in collections and documents. Here’s a quick overview of the data structure:

  • Database: Contains collections, similar to tables in relational databases.
  • Collection: Contains multiple documents.
  • Document: Composed of fields, which are key-value pairs.

The data is stored in BSON (Binary JSON) format, which allows for efficient storage and retrieval.

Conclusion

Learning MongoDB offers several benefits for database administrators (DBAs). It provides the ability to handle complex data structures and support for horizontal scaling. By following this guide, hope you can easily understand the overview of MongoDB history and architecture.

Discover more from Genexdbs

Subscribe now to keep reading and get access to the full archive.

Continue reading