What Is MongoDB?
You are building a bookshop app. In your code, a book is already one object: a title, an author, a price, a list of genres, a publisher. A document database lets you save that object much as it is, instead of taking it apart to fit a grid. MongoDB is the most widely used database that works this way.
The rule
One record, one document: store the thing whole, the way your app holds it.
A document is a set of field and value pairs, written in a JSON-like style. Values can be plain (text, numbers, dates) or rich: a nested object, or an array of values.
{
title: "Dune",
author: "Frank Herbert",
price: 9.99,
genres: ["sci-fi", "classic"],
publisher: { name: "Chilton", country: "US" }
}Unpack the rule:
- One record is one real-world thing: a book, a user, an order.
- One document means all of that thing's data lives together. Reading the book is one lookup, not a join across tables.
- The way your app holds it: the document's shape mirrors the object in your code, so there is little translation between the two.
Documents live in collections, and collections live in databases. You talk to MongoDB from the mongosh shell or from a language driver (Python, JavaScript, Java and many more).
MongoDB Atlas is MongoDB run for you in the cloud. You create a cluster on AWS, Google Cloud or Azure through a web page, Atlas handles servers, backups, upgrades and monitoring, and you connect with a connection string that starts with mongodb+srv://. There is a free starter tier, which is enough for this whole course. You can also install MongoDB yourself; the queries are identical.
The shortcut
When you meet a new piece of data, picture the object your app would build for it. That object is your document.
Picture the object
The app shows a book page: title, author, price, genres and publisher details.
The trap is thinking "document" means "no structure". Documents are structured; they are simply allowed to nest, and two documents in one collection may differ when the data truly differs.
Drills
Answer fast — trust the rule.
What does MongoDB store as a single record?
A book has four genres. Where do they go in the book's document?
What is MongoDB Atlas?
Which statement about MongoDB documents is true?
Remember
- One record, one document: store the thing whole, as your app holds it.
- Shortcut: picture the object your code builds; fields, arrays and nested objects map straight across.
- Atlas is MongoDB hosted for you; the database and queries are the same.
