Advanced NoSQL Lab Tasks
Advanced NoSQL Lab Tasks
db.students.insertOne({
name: "Hassan Raza",
age: 22,
semester: 6,
courses: [
{ subject: "Database Systems", marks: 85 },
{ subject: "Artificial Intelligence", marks: 90 }
]
})
db.students.updateOne(
{ name: "Hassan Raza", "courses.subject": "Database Systems" },
{ $set: { "courses.$.marks": 95 } }
)
db.students.updateOne(
{ name: "Hassan Raza" },
{ $pull: { courses: { subject: "Artificial Intelligence" } } }
)
db.students.updateOne(
{ name: "Sara Ahmed" },
{ $push: { hobbies: "Traveling" } }
)
db.students.updateOne(
{ name: "Sara Ahmed" },
{ $pull: { hobbies: "Swimming" } }
)
use admin
db.createUser({
user: "labAdmin",
pwd: "securepassword123",
roles: [{ role: "userAdminAnyDatabase", db: "admin" }]
})
use StudentDB
db.createUser({
user: "readonlyUser",
pwd: "readonly123",
roles: [{ role: "read", db: "StudentDB" }]
})
db.students.createIndex({ name: 1 })
Drop an Index:
db.students.dropIndex({ name: 1 })
mongoose.connect("mongodb://localhost:27017/StudentDB", {
useNewUrlParser: true,
useUnifiedTopology: true
}).then(() => console.log("Connected to MongoDB"))
.catch(err => console.log("MongoDB connection error:", err));
node server.js
http://localhost:3000/students
Students will:
1. Create a complete database system for a University Management System.
2. Implement:
- Students collection (name, age, semester, courses, grades).
- Professors collection (name, department, experience).
- Courses collection (course name, professor, credits).
3. Apply CRUD operations, aggregation, and indexing.
4. Integrate MongoDB with Python or Node.js for data retrieval.
5. Secure the database with authentication & backup features.
6. Submit a report with screenshots of all tasks performed.