Skip to content
Learn Netverks

Lesson

Step 1/36 3% through track

intro

Introduction to MongoDB

Last reviewed May 28, 2026 Content v20260528
Track mode
none
Means
Read / quiz
Reading
~3 min
Level
beginner

This lesson

An orientation to the MongoDB track—documents, queries, and when document stores beat relational tables.

You need a clear map of the MongoDB track so documents, aggregation pipelines, and schema flexibility do not feel like magic.

You will apply Introduction to MongoDB in contexts like: Content catalogs, event logs, mobile sync backends, and polyglot stacks beside SQL services.

Copy JavaScript shell queries from each lesson into mongosh or MongoDB Atlas Data Explorer—inspect matched documents and explain plans. The in-browser lab (execution_profile: none) ships later; mongosh is the practice path now. Also read the interview prep blocks.

After you understand JSON and SQL trade-offs—when document flexibility outweighs relational joins.

How this MongoDB track works

  • Read-focused — no in-browser Mongo lab yet — copy queries into mongosh, MongoDB Atlas (free tier), or Compass. The track uses execution_profile: none; the playground is not wired yet.
  • Document-first — BSON documents, operators, aggregation pipelines, and schema design trade-offs after you understand JSON and relational SQL on SQL.
  • Pair withPython (PyMongo) and Node.js (Mongoose) for app integration; compare PostgreSQL when JSONB covers your semi-structured needs.
  • Prerequisites — comfortable with JSON objects/arrays and basic SQL (SELECT, WHERE) so you can reason about when documents beat tables.

Practice on databases you create. Never run destructive commands on production clusters.

Install on your device (macOS, Linux, Windows)

Use MongoDB Atlas (cloud) free tier or install Community Server locally.

macOS

  1. brew tap mongodb/brew && brew install mongodb-community or use Atlas.

Linux

  1. Follow MongoDB Linux install for your distro, or Atlas.

Windows

  1. MongoDB Installer or Atlas; winget install MongoDB.Server where available.

Verify: mongosh --version and connect to mongodb://localhost:27017 or Atlas URI.

Atlas: create a free cluster, add database user, allow your IP, copy connection string into mongosh.

MongoDB is a document database: data lives in BSON documents grouped into collections (like tables without fixed columns). This track teaches queries, schema design, aggregation, and operations—after you can read JSON and basic SQL from the SQL track.

Prerequisites and how this track works

Understand JSON objects/arrays and SQL SELECT/WHERE so you can compare document stores to relational tables. This track is read-focused (execution_profile: none): copy examples into mongosh or Atlas—no in-browser Mongo lab yet.

When semi-structured data fits one document, MongoDB shines; when many-to-many joins dominate, see PostgreSQL (JSONB) or core SQL.

What you will learn

  • mongosh, BSON types, ObjectId, CRUD with operators
  • Schema flexibility, validators, indexes (compound, text)
  • Aggregation: $match, $group, $lookup, $unwind
  • Transactions, replication, sharding preview, security, change streams, Atlas

Ping the server

// In mongosh after connecting:
use practice
db.runCommand({ ping: 1 })

Practice: Copy queries into mongosh, MongoDB Atlas Data Explorer, or Compass. Use a database named practice you create for learning.

ok: 1 confirms the server is reachable—do this before longer lessons.

Safety note

Never run dropDatabase or unscoped deleteMany({}) on shared clusters. Use separate practice databases and least-privilege users in production.

Important interview questions and answers

  1. Q: Why learn MongoDB after SQL?
    A: You can choose the right datastore—documents for flexible catalogs and logs; SQL for heavy relational reporting.
  2. Q: What is a collection?
    A: A named container of documents in a database—analogous to a table but without enforced identical columns per row.

Self-check

  1. What tracks should you understand before starting?
  2. What does db.runCommand({ ping: 1 }) verify?

Challenge

Connect with mongosh and verify MongoDB

  1. Install MongoDB locally or create a free Atlas cluster.
  2. Open mongosh and connect to your practice database.
  3. Run db.runCommand({ ping: 1 }) and read ok: 1.

Done when: you see a successful ping response from the server.

Tip: Run the ping challenge before moving on—later lessons assume mongosh works.

Interview prep

Prerequisite tracks?
JSON literacy and basic SQL (/sql/intro) before document-specific modeling.
Why read-focused?
execution_profile: none—practice in mongosh or Atlas until an in-browser lab ships.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • Why Mongo after SQL?
  • mongosh or Atlas?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump