MongoDB — What is MongoDB & NoSQL?
Welcome to Chapter 1 of the MongoDB Masterclass! In this lesson, we break down what NoSQL is, why modern web applications rely heavily on document databases, and how MongoDB stores data as flexible BSON documents.
For decades, software development was dominated by Relational Database Management Systems (RDBMS) like MySQL, PostgreSQL, and Oracle. In relational databases, data is organized into fixed tables, rows, and columns. While this structure works well for tabular data, it creates friction when working with modern object-oriented programming languages and rapidly evolving application requirements.
NoSQL (which stands for "Not Only SQL") represents a category of databases designed to handle diverse data models — including key-value pairs, wide-column stores, graphs, and documents. MongoDB is the world's leading document-oriented NoSQL database.
- Unstructured & Semi-Structured Data: Modern apps process social feeds, JSON payloads, sensor logs, and media metadata that don't fit neatly into rigid tables.
- Agile Development: Changing a SQL table schema requiring
ALTER TABLEcan lock production tables and cause downtime. NoSQL document databases are schema-flexible. - Horizontal Scalability: Traditional SQL databases scale vertically (buying larger hardware). NoSQL databases like MongoDB scale horizontally out-of-the-box using sharding across cheap commodity clusters.
To transition smoothly to MongoDB, it is helpful to map traditional SQL database concepts to their MongoDB equivalents:
| SQL Relational Concept | MongoDB Concept | Detailed Description |
|---|---|---|
| Database | Database | A container holding related collections of data. |
| Table | Collection | A grouping of BSON documents (equivalent to a table without strict column definitions). |
| Row / Record | Document | A single self-contained data record expressed as BSON (Binary JSON). |
| Column | Field | A key-value pair inside a document. |
| Primary Key | _id Field | Unique identifier automatically generated for every document. |
| Table Join | Embedded Document / $lookup | Related data is embedded inside the document or joined using the $lookup stage. |
MongoDB stores data as BSON (Binary JSON). In code, documents look like standard JSON objects with support for rich data types such as dates, 64-bit integers, and ObjectIds.
{
"_id": ObjectId("65d8f1e2a9b3c4d5e6f7a8b9"),
"username": "tech_guru",
"email": "guru@ourcompiler.com",
"age": 28,
"isVerified": true,
"skills": ["JavaScript", "Node.js", "MongoDB", "Docker"],
"profile": {
"firstName": "Balaji",
"lastName": "Nayak",
"avatar": "https://example.com/avatar.png"
},
"loginCount": 142,
"createdAt": ISODate("2026-08-26T10:15:30.000Z")
}
Notice how the profile key contains an embedded object and skills contains an array of strings. In SQL, this single record would require three separate tables (users, profiles, user_skills) connected with foreign key JOINs.
MongoDB is trusted by industry giants like Forbes, eBay, Adobe, and Uber for critical systems. Key architectural features include:
- WiredTiger Storage Engine: Provides document-level concurrency control, memory caching, and data compression (Snappy / Zlib).
- High Availability (Replication): Uses 3-node Replica Sets with automatic failover to guarantee 99.999% uptime.
- Horizontal Scalability (Sharding): Automatically partitions collections across multiple database instances based on a shard key.
- Rich Aggregation Framework: Allows complex data transformations, grouping, and analytics directly inside the database.
Think about a Blogging Application. Write down the JSON structure of a Post document that includes the post title, content, author information, tags array, and a list of embedded comments (with commenter name and text). Compare how many SQL tables would be needed for the same feature!