Hi,
I am trying to create my own schema design and I have searched on Google on how to do this and read the MongoDB documentation to the best of my ability.
This is my first MongoDB schema design that is based on what I wanted to do.
I want to model my school attendance management system and I should be able to satisfy the following requirements.
-
Create a record or list of students enrolled in my university
-
Create a list of classes and the students enrolled per each class
-
Record the attendance per each class session including the time in and time out of each student.
I have developed the following schema design and would like to ask for expert advice if this is optimal.
// Students collection
{
_id: "joe",
name: "Joe Bookreader"
},
{
_id: "jane",
name: "Jane Shaw"
}
// Classes collection
{
_id: "Physics 101",
year: "2023",
semester: "first"
professor: "Dr James Grunfield"
location: "Room 123"
students: ["joe", "jane", ....] // references Students collection _id
}
// Classes Attendance collection
{
_id: "Physics - Session 1",
class_id: "Physics 101" // references the classes collection _id
date: new ISODate("2023-07-03T08:00:00Z"),
attendance: [
{
student_id: "jane", // references Students collection _id
time_in: new ISODate("2023-07-03T08:00:00Z"),
time_out: new ISODate("2023-07-03T11:00:00Z")
},
{
student_id: "joe", // references Students collection _id
time_in: new ISODate("2023-07-03T08:00:00Z"),
time_out: new ISODate("2023-07-03T11:00:00Z")
},
]
}
In terms of data query, I would like to do the following
-
Execute CRUD operations on my students
-
Execute CRUD operations on my class collection. Able to add, edit, and delete, students enrolled in the class.
-
View the list of students that joined each class schedule
Let me know what you think of my design. I am very much eager for expert comments, please. Thank you!