Assignment


1️⃣ Introduction to MongoDB (4 Assignments)

Assignment 1: Installing and Setting Up MongoDB

🔹 Task: Install MongoDB on your system and start the MongoDB server. 🔹 Example Command (Terminal):

sudo systemctl start mongod  # Start MongoDB
mongo  # Open MongoDB shell

Assignment 2: Creating a Database in MongoDB

🔹 Task: Create a database named mydatabase in the MongoDB shell. 🔹 Example Command (MongoDB Shell):

use mydatabase

Assignment 3: Creating a Collection in MongoDB

🔹 Task: Create a collection named users inside mydatabase. 🔹 Example Command (MongoDB Shell):

db.createCollection("users")

Assignment 4: Viewing All Collections in a Database

🔹 Task: List all collections inside mydatabase. 🔹 Example Command (MongoDB Shell):


2️⃣ Connecting MongoDB with Python (pymongo) (6 Assignments)

Assignment 5: Installing pymongo

🔹 Task: Install pymongo Python library. 🔹 Example Command (Terminal):


Assignment 6: Connecting to MongoDB using pymongo

🔹 Task: Establish a connection to MongoDB in Python. 🔹 Example Snippet:


Assignment 7: Creating a New Database Using pymongo

🔹 Task: Create a database named company. 🔹 Example Snippet:


Assignment 8: Creating a Collection Using pymongo

🔹 Task: Create a collection named employees. 🔹 Example Snippet:


Assignment 9: Listing All Databases in MongoDB

🔹 Task: Retrieve a list of all databases using pymongo. 🔹 Example Snippet:


Assignment 10: Listing All Collections in a Database

🔹 Task: Retrieve all collections inside company database. 🔹 Example Snippet:


3️⃣ CRUD Operations in MongoDB (10 Assignments)

Assignment 11: Inserting a Single Document into a Collection

🔹 Task: Insert one employee into the employees collection. 🔹 Example Snippet:


Assignment 12: Inserting Multiple Documents into a Collection

🔹 Task: Insert multiple employees into the employees collection. 🔹 Example Snippet:


Assignment 13: Finding a Single Document in a Collection

🔹 Task: Retrieve one employee from the collection. 🔹 Example Snippet:


Assignment 14: Retrieving All Documents from a Collection

🔹 Task: Retrieve all employees from the employees collection. 🔹 Example Snippet:


Assignment 15: Filtering Documents Using a Query

🔹 Task: Retrieve employees whose age is greater than 27. 🔹 Example Snippet:


Assignment 16: Updating a Single Document in a Collection

🔹 Task: Update the department of "John Doe" to "Management". 🔹 Example Snippet:


Assignment 17: Updating Multiple Documents in a Collection

🔹 Task: Increase the age of all employees by 1. 🔹 Example Snippet:


Assignment 18: Deleting a Single Document from a Collection

🔹 Task: Delete an employee with the name "Alice". 🔹 Example Snippet:


Assignment 19: Deleting Multiple Documents from a Collection

🔹 Task: Delete all employees in the HR department. 🔹 Example Snippet:


Assignment 20: Dropping a Collection

🔹 Task: Drop the employees collection. 🔹 Example Snippet:


Last updated