Loading lessons...
What is MongoDB?
What is MongoDB?
MongoDB is a document database. Instead of storing data in tables and rows like a SQL database, it stores data in documents, which look a lot like JSON objects.
A record is a document
In MongoDB, a single record is called a document - a data structure made of field and value pairs, similar to a JSON object:
{
title: "Post Title 1",
body: "Body of post.",
category: "News",
likes: 1,
tags: ["news", "events"],
date: Date()
}
Field values can be numbers, strings, booleans, arrays, or even whole nested documents.
Why "document" database?
Documents map naturally to the objects you already use in code. A JavaScript object, a Python dict, or a Java class instance all look like a MongoDB document. This means no complex mapping layer between your code and the database.
BSON under the hood
MongoDB stores documents in a type of JSON format called BSON (Binary JSON). It's the binary serialization format MongoDB actually writes to disk, and it supports a few extra types that plain JSON can't express - like dates, ObjectIds, and 32-bit integers.
Key ideas
- MongoDB is non-relational (often called NoSQL).
- Data lives in flexible documents, not rigid tables.
- The format is JSON-like but stored as BSON.
- Document field values can be arrays or nested documents.
TL;DR
- MongoDB = document database, records are called documents.
- Documents look like JSON objects and are stored as BSON.
- No tables or fixed columns - just flexible documents.