0
0
MongoDBquery~30 mins

Document model mental model (JSON/BSON) in MongoDB - Mini Project: Build & Apply

Choose your learning style9 modes available
Building a Simple MongoDB Document Model
📖 Scenario: You are creating a small database for a local bookstore. The store wants to keep track of books with details like title, author, and price.
🎯 Goal: Build a MongoDB document model using JSON/BSON format to represent books in the bookstore.
📋 What You'll Learn
Create a document representing a book with specific fields
Add a configuration field for currency
Use a query to find books cheaper than a certain price
Complete the document with an additional field for stock quantity
💡 Why This Matters
🌍 Real World
Document models like this are used in MongoDB to store and organize data for applications such as online stores, libraries, and inventory systems.
💼 Career
Understanding how to structure documents and write queries is essential for roles like database administrators, backend developers, and data engineers working with NoSQL databases.
Progress0 / 4 steps
1
Create the initial book document
Create a MongoDB document called book with these exact fields and values: title set to "The Great Gatsby", author set to "F. Scott Fitzgerald", and price set to 10.99.
MongoDB
Need a hint?

Use curly braces to create a document and include the fields exactly as shown.

2
Add a currency field
Add a field called currency to the book document and set it to "USD".
MongoDB
Need a hint?

Add the new field inside the existing document with a comma separating it from previous fields.

3
Query for books cheaper than a price
Write a MongoDB query called cheap_books_query that finds books with price less than 15.
MongoDB
Need a hint?

Use MongoDB's query operator $lt to find prices less than 15.

4
Add stock quantity to the book document
Add a field called stock to the book document and set it to 30.
MongoDB
Need a hint?

Add the stock field with a comma after the previous field inside the document.