Skip to content

You are viewing a free preview of this lesson.

Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.

What is MongoDB?

What is MongoDB?

MongoDB is a document-oriented NoSQL database released in 2009 by MongoDB Inc. Rather than storing data in rows and columns like a relational database, MongoDB stores data as flexible JSON-like documents, making it a natural fit for applications that deal with hierarchical or variable-structure data.

The NoSQL Movement

NoSQL (Not Only SQL) databases emerged in the late 2000s to address scalability and flexibility challenges that relational databases struggled with at web scale. There are several NoSQL categories: key-value stores, column-family stores, graph databases, and document databases. MongoDB is the most popular document database in the world.

Unlike SQL databases, MongoDB does not require a fixed schema. You can store documents with different fields in the same collection, and you can evolve your data model without running ALTER TABLE migrations.

How MongoDB Stores Data

MongoDB stores data in a format called BSON (Binary JSON). BSON extends JSON with additional data types such as Date, ObjectId, Decimal128, and binary data. From a developer perspective you interact with ordinary JavaScript objects, and the driver handles BSON serialisation transparently.

A document looks like this:

{
  _id: ObjectId("64a1f2c3d4e5f6a7b8c9d0e1"),
  name: "Alice",
  age: 30,
  email: "alice@example.com",
  address: {
    city: "London",
    postcode: "EC1A 1BB"
  },
  hobbies: ["reading", "cycling"]
}

MongoDB vs Relational Databases

Concept Relational DB MongoDB
Storage unit Row Document
Grouping Table Collection
Schema Fixed Flexible
Joins SQL JOIN Embedded docs / $lookup
Transactions Full ACID Multi-doc ACID (v4+)

When to Use MongoDB

MongoDB excels when your data is naturally hierarchical, when requirements change frequently, or when you need to scale horizontally across many servers. Common use cases include content management systems, e-commerce catalogues, real-time analytics, mobile backends, and IoT data ingestion.

It is less ideal for applications with heavy relational data and complex multi-table joins, or when strict financial-grade transactional integrity is the primary concern.

The MongoDB Ecosystem

Beyond the database server itself, MongoDB provides MongoDB Atlas (a fully managed cloud service), Compass (a GUI for exploring data), mongosh (the modern interactive shell), and official drivers for every major programming language. This rich ecosystem makes it easy to develop, visualise, and deploy MongoDB-backed applications.

Understanding what MongoDB is and where it fits in the database landscape prepares you for the hands-on lessons ahead.