CTCaliberTek
Course: MongoDB: From Documents to Production, Step by Step · Lesson 1 of 8Log in to track your progress and earn a certificate when you finish the course.
Data Engineering & Analytics

MongoDB Module 1: Introduction, the Document Model, and Setup

Published October 6, 2026·Updated October 29, 2026·9 min read
Like SaveLog in to like, save, and track progress.

Introduction

MongoDB is a document database: instead of rows in tables, it stores flexible JSON-like documents in collections. This makes it a natural fit for application data whose shape changes, nested data, and event data. This first module of the eight-module MongoDB course explains the model and gets a database running so you can try every example.

Prerequisites

  • Basic JSON knowledge
  • Docker installed, or a free MongoDB Atlas account

Step-by-Step Guide

Step 1: Compare documents with rows

A relational table has fixed columns and every row looks the same. A MongoDB collection holds documents that can have different fields, nested objects, and arrays. A document is stored as BSON, a binary form of JSON that adds types such as dates and 64-bit integers. Each document has a unique _id field.

// A document with a nested object and an array
{
  "_id": ObjectId("65f1c2a4b7d3a1e0c8a91f01"),
  "name": "Asha Rao",
  "email": "asha@example.com",
  "address": { "city": "Pune", "country": "India" },
  "interests": ["data", "cycling"],
  "createdAt": ISODate("2026-10-06T09:30:00Z")
}

Step 2: Learn the vocabulary

A database holds collections, and a collection holds documents. Collections are created the first time you insert into them, and fields can differ between documents (though you can enforce rules with validation, covered later). The query language works with JSON-style documents instead of SQL text.

Relational        MongoDB
database          database
table             collection
row               document
column            field
join              $lookup or embedding (covered later)
primary key       _id

Step 3: Run MongoDB locally with Docker

The quickest way to practice is a container. Start MongoDB on the default port, then open a shell inside it. This is for learning only: do not expose an unsecured database to the internet.

docker run -d --name mongo-lab -p 27017:27017 mongo:8
docker exec -it mongo-lab mongosh

Step 4: Or use a free Atlas cluster

MongoDB Atlas is the managed cloud service. Create an account, create a free cluster, add your IP address to the access list, create a database user, and copy the connection string. Free clusters have tight limits (for example one free cluster per project, limited storage, connections, and throughput), so check the current free-tier documentation, and do not store real sensitive data on them.

# connect with mongosh using the string from Atlas
mongosh "mongodb+srv://<user>:<password>@<cluster>.mongodb.net/shop"

Step 5: Take your first steps in mongosh

mongosh is an interactive JavaScript shell. Switch to a database with use, insert a document, and read it back. You can also use MongoDB Compass, the free graphical tool, to browse the data.

use shop
db.customers.insertOne({ name: "Asha Rao", city: "Pune" })
db.customers.find()
db.getCollectionNames()
show dbs

FAQs

Is MongoDB schemaless?
It is schema-flexible: the database does not force one structure, but your application and your queries still assume one. Good MongoDB projects design the document shape deliberately and can enforce it with schema validation.

Summary

MongoDB stores flexible BSON documents in collections. Run it with Docker or a free Atlas cluster, connect with mongosh or Compass, and remember that flexible does not mean unplanned.

Related tutorials

Comments

Log in or create a free account to join the discussion.

  • No comments yet. Be the first to comment.