Skip to main content

Module 14 — MongoDB & Mongoose

SQL vs NoSQL — When to Use Each

PostgreSQL (SQL)MongoDB (NoSQL)
Data shapeStructured, fixed schemaFlexible, schema-optional
RelationsStrong (foreign keys)Weak (manual references)
QueriesSQL — powerful and standardizedMongoDB query language
ScalingVertical (bigger server)Horizontal (more servers)
Best forFinancial data, relationsDocuments, flexible content
Use caseE-commerce, bankingCMS, analytics, real-time

Use both. Most real applications use SQL for core data and MongoDB for flexible/high-volume content.

Learning Objectives

  • Create MongoDB databases and collections
  • Perform CRUD operations with the MongoDB shell and Mongoose
  • Define schemas with validation in Mongoose
  • Work with subdocuments and references
  • Use aggregation pipelines for complex queries

Module Lessons

  1. MongoDB Intro
  2. Mongoose Schemas
  3. CRUD & Aggregations
  4. When to Use NoSQL

Challenge

Build a Social Network API — users, thoughts (posts), reactions (comments), and friends.

View Challenge →