Skip to the workspace
Pebellslearn by building
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.

mongodb / What Is MongoDB?

Explore each scene at your own pace.

01 · The rule

The rule

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.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.