Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
MongoDB Basics  ›  Lesson

What Is MongoDB?

What is MongoDB? 12 minMongoDB is a document database that stores each record as a self-contained, JSON-like document, and Atlas is MongoDB's hosted cloud service for running it.

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.

Turning a book into a documentStep 1 of 4
  1. 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.

quick drill

What does MongoDB store as a single record?

quick drill

A book has four genres. Where do they go in the book's document?

quick drill

What is MongoDB Atlas?

quick drill

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.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainA book as a document

A friend who knows spreadsheets asks what MongoDB actually stores. Using a single book in a bookshop as your example, explain what a document is, how it differs from a spreadsheet row, and what MongoDB Atlas adds.