0
0
MongoDBquery~30 mins

What is MongoDB - Hands-On Activity

Choose your learning style9 modes available
Introduction to MongoDB Basics
📖 Scenario: You are starting a new project to store information about your favorite books using MongoDB, a popular database system that stores data in a way similar to how you organize notes in folders.
🎯 Goal: Learn how to create a MongoDB collection and insert simple documents representing books.
📋 What You'll Learn
Create a MongoDB database named library
Create a collection named books
Insert at least two book documents with fields title and author
Use MongoDB shell commands or equivalent syntax
💡 Why This Matters
🌍 Real World
MongoDB is used to store flexible data like user profiles, product catalogs, or any information that changes often and doesn't fit neatly into tables.
💼 Career
Knowing MongoDB basics helps in roles like backend development, data engineering, and working with modern web applications that require fast, scalable databases.
Progress0 / 4 steps
1
Create the library database
Switch to the MongoDB database called library using the command use library.
MongoDB
Need a hint?

Use the use command to select or create a database.

2
Create the books collection
Create a collection named books by inserting a document with title and author fields. Use db.books.insertOne() with the document { title: "1984", author: "George Orwell" }.
MongoDB
Need a hint?

Use db.collection.insertOne() to add a document.

3
Add another book document
Insert a second book document into the books collection with title as "To Kill a Mockingbird" and author as "Harper Lee" using db.books.insertOne().
MongoDB
Need a hint?

Repeat the insertOne command with the new book details.

4
View all books in the collection
Retrieve all documents from the books collection using db.books.find() to see the inserted books.
MongoDB
Need a hint?

Use find() to list all documents in a collection.