Understanding Tables vs Collections Thinking in MongoDB
📖 Scenario: You are helping a small bookstore organize its data. The bookstore wants to store information about books and their authors. You will practice thinking in terms of tables (like in SQL) and collections (in MongoDB) to understand how data is structured differently.
🎯 Goal: Build a MongoDB collection that stores books with embedded author information, practicing the collection thinking approach instead of separate tables.
📋 What You'll Learn
Create a collection named
books with documents for three books.Each book document must include
title, year, and an embedded author document.The
author document must have name and birthYear fields.Create a variable
minYear to filter books published after this year.Write a MongoDB query to find all books published after
minYear.Add a projection to show only the
title and author.name fields in the query result.💡 Why This Matters
🌍 Real World
Many modern applications use MongoDB to store data as collections of documents. Understanding how to structure data and query it is essential for building flexible and scalable apps.
💼 Career
Database developers and backend engineers often work with MongoDB. Knowing how to think in collections and write queries helps you design efficient data models and retrieve data quickly.
Progress0 / 4 steps