Exercises, Interview & Next Steps
Practice cements theory. Complete these exercises on a local replica set or Atlas free tier. Save your mongosh scripts and Mongoose code in a GitHub repo for portfolio proof.
Hands-on exercises
Practice cements theory. Complete these exercises on a local replica set or Atlas free tier. Save your mongosh scripts and Mongoose code in a GitHub repo for portfolio proof.
Real-life example: Exercises are gym reps for your database skills — interviews test whether you can lift real queries under pressure, not just read the manual.
- Design schemas for a food delivery app: restaurants, menus (embedded), orders (embedded line items + userId reference), drivers. Justify embed vs reference for each.
- Implement inventory deduction + order creation as a Mongoose transaction. Simulate failure (out of stock) and verify rollback.
- Add $jsonSchema validation to an orders collection — required fields, status enum, minimum one line item.
- Set up a 3-node replica set locally (or Atlas). Test readPreference secondaryPreferred and observe stale reads.
- Build signup/login API with Express, Mongoose, bcrypt. Protect a /api/my-courses route with JWT middleware.
- Write aggregation pipelines: revenue by month, top 10 products by quantity sold, active users in last 7 days.
- Create indexes for your heaviest queries; run explain() before and after and document the improvement.
- Enable auth on your cluster. Create readWrite and read-only users. Connect via environment variable only.
Interview question themes
MongoDB interviews focus on practical design and query skills, not trivia. Expect live coding in mongosh or a driver, schema design whiteboards, and trade-off discussions.
- CRUD — write find/update/delete queries with operators ($gt, $in, $elemMatch, $regex). Explain findOneAndUpdate vs updateOne.
- Indexing — ESR rule, compound indexes, unique indexes, partial indexes, TTL indexes. Interpret explain() output (IXSCAN vs COLLSCAN).
- Aggregation — build pipelines with $match, $group, $lookup, $unwind, $project. When to use aggregation vs find.
- Data modeling — embed vs reference, unbounded arrays, hybrid patterns, anti-patterns (massive documents, too many indexes).
- Transactions — when to use, single-document atomicity vs multi-document, performance cost.
- Replication & sharding — replica set failover, read preferences, write concern, shard key selection, hot shards.
- Security — RBAC, NoSQL injection prevention, TLS, connection string secrets.
- Mongoose — schema design, middleware, lean(), populate pitfalls, session.withTransaction().
Continue learning on Rishtaara
- MCQ Quiz — test fundamentals quickly: /mcq/mongodb-mcq
- Interview prep — common questions with model answers: /interview/mongodb-interview
- Knowledge hub — full MongoDB reference: /knowledge/mongodb-fundamentals
- SQL course — compare relational vs document thinking: /learn/data-science/sql-zero-to-analyst
Online quiz and next courses
Take the Rishtaara MongoDB MCQ quiz until you score 85%+ twice in a row — that usually means the core concepts have stuck. Then attempt the interview question set under timed conditions.
From here, explore adjacent Rishtaara paths: Node.js backend patterns, Next.js full-stack with MongoDB API routes, or data engineering with aggregation-heavy pipelines.
Real-life example: Finishing this course is earning your motorcycle license — you can ride solo now, but highway traffic (production sharding, multi-region failover) comes with more miles.