This project involves designing and querying a MongoDB database for a Zen class program. The database includes collections for users, attendance, tasks, topics, company_drives, and mentors. Below is a summary of the tasks performed and queries used.
Tracks user attendance with fields:
user_id
: ID of the user.date
: Attendance date (ISODate format).attendance
: Status ("Present"
or"Absent"
).
Tracks tasks assigned to users:
topic_id
: ID of the related topic.title
: Task title.due_date
: Task due date.status
: Task completion status ("Pending"
or"Completed"
).
- Find all topics and tasks taught in October.
- Retrieve company drives conducted between 15-Oct-2020 and 31-Oct-2020.
- List company drives along with students who appeared for placements.
- Count the number of problems solved by users in
codekata
. - Retrieve mentors with a mentee count greater than 15.
- Identify users who were absent and didn’t submit tasks between 15-Oct-2020 and 31-Oct-2020.
db.attendance.aggregate([
{
$match: {
date: {
$gte: ISODate("2020-10-15T00:00:00Z"),
$lte: ISODate("2020-10-31T00:00:00Z")
},
attendance: "Absent"
}
},
{
$lookup: {
from: "tasks",
localField: "user_id",
foreignField: "user_id",
as: "tasks"
}
},
{
$unwind: "$tasks"
},
{
$match: {
"tasks.status": "Pending"
}
},
{
$project: {
user_id: 1,
date: 1,
"tasks.title": 1,
"tasks.status": 1
}
}
]);
- Topics and Tasks for October: Retrieved based on the
date
field. - Company Drives in Date Range: Filtered using
$gte
and$lte
. - Absent Users with Pending Tasks: Identified using
$lookup
,$unwind
, and$match
.