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 with — Python (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
brew tap mongodb/brew && brew install mongodb-communityor use Atlas.
Linux
- Follow MongoDB Linux install for your distro, or Atlas.
Windows
- MongoDB Installer or Atlas;
winget install MongoDB.Serverwhere 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
- Q: Why learn MongoDB after SQL?
A: You can choose the right datastore—documents for flexible catalogs and logs; SQL for heavy relational reporting. - 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
- What tracks should you understand before starting?
- What does db.runCommand({ ping: 1 }) verify?
Challenge
Connect with mongosh and verify MongoDB
- Install MongoDB locally or create a free Atlas cluster.
- Open
mongoshand connect to your practice database. - Run
db.runCommand({ ping: 1 })and readok: 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.