0
0
MongoDBquery~30 mins

Database and collection creation in MongoDB - Mini Project: Build & Apply

Choose your learning style9 modes available
Create a MongoDB Database and Collection
📖 Scenario: You are setting up a new MongoDB database for a small bookstore. You need to create the database and a collection to store book information.
🎯 Goal: Create a MongoDB database called bookstore and a collection inside it called books.
📋 What You'll Learn
Create a database named bookstore
Create a collection named books inside the bookstore database
💡 Why This Matters
🌍 Real World
Creating databases and collections is the first step in organizing data for any application that uses MongoDB, such as inventory systems, content management, or user data storage.
💼 Career
Database administrators and backend developers often create and manage MongoDB databases and collections to store and retrieve application data efficiently.
Progress0 / 4 steps
1
Create the bookstore database
Switch to the MongoDB database named bookstore using the command use bookstore.
MongoDB
Need a hint?

Use the use command to switch to the database.

2
Create the books collection
Create a collection named books in the bookstore database using db.createCollection('books').
MongoDB
Need a hint?

Use db.createCollection('books') to create the collection.

3
Verify the collection creation
List all collections in the bookstore database using show collections to confirm books exists.
MongoDB
Need a hint?

Use show collections to see all collections in the current database.

4
Insert a sample document into books
Insert a sample book document into the books collection using db.books.insertOne({ title: 'The Great Gatsby', author: 'F. Scott Fitzgerald' }).
MongoDB
Need a hint?

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