📘 Objective
In this post, we’ll explore how to perform CRUD (Create, Read, Update, Delete) operations in MongoDB using a simple College Student schema.
This activity helped me understand how MongoDB stores data in collections and how to interact with it using queries.
🧩 Schema – Collection: students
Each document in the collection follows this structure:
{
"student_id": "S001",
"name": "Santhosh",
"age": 20,
"department": "CSBS",
"year": 2,
"cgpa": 9
}
⚙️ 1️⃣ Create (Insert)
Insert multiple student records:
db.students.insertMany([
{ "student_id": "S001", "name": "Santhosh", "age": 20, "department": "CSBS", "year": 2, "cgpa": 9 },
{ "student_id": "S002", "name": "Deepa", "age": 19, "department": "CSE", "year": 1, "cgpa": 8.7 },
{ "student_id": "S003", "name": "Meena", "age": 21, "department": "IT", "year": 3, "cgpa": 7.9 },
{ "student_id": "S004", "name": "Kavin", "age": 22, "department": "CSBS", "year": 3, "cgpa": 8.4 },
{ "student_id": "S005", "name": "Arun", "age": 20, "department": "EEE", "year": 2, "cgpa": 6.9 }
])
🔍 2️⃣ Read (Query)
📌 Display all student records:
db.students.find()
📌 Find students with CGPA > 8:
db.students.find({ cgpa: { $gt: 8 } })
📌 Find students belonging to the Computer Science
db.students.find({ department: { $regex: "CS", $options: "i" } })
✏️ 3️⃣ Update
📌 Update the CGPA of a specific student:
db.students.updateOne({ student_id: "S002" }, { $set: { cgpa: 9.1 } })
📌 Increase the year of study for all 3rd year students by 1:
db.students.updateMany({ year: 3 }, { $inc: { year: 1 } })
🗑️ 4️⃣ Delete
📌 Delete one student record by student_id:
db.students.deleteOne({ student_id: "S005" })

📌 Delete all students having CGPA < 7.5:
db.students.deleteMany({ cgpa: { $lt: 7.5 } })
📤 Deliverables
✅ MongoDB queries (insert, find, update, delete)
✅ Screenshots from MongoDB Atlas showing query outputs
✅ Export of the final students collection in JSON/CSV format
💡 Summary
Through this exercise, I learned how MongoDB handles data in a document-based structure and how CRUD operations can be done easily using built-in commands.
🙏 Special Thanks
A special thanks to Santhosh NC Sir for his guidance and continuous support in this DBMS learning journey.





Top comments (0)