I have begun diving into the server side of things lately, and am working on an app where I need to think about how I plan my models.
My users are teachers, and in the dashboard will have the ability to create a list of students. My schema's will contain more directives to prevent duplicates being created, but I have simplified them here. Here's what I have attempted so far:
// Teacher Model
const Teacher = new Schema({
fname: String,
lname: String,
email: String,
})
// Student Model
const Student = new Schema({
fname: String,
lname: String,
full: String,
uuid: String
grades: {
classwork: Array,
quizzes: Array,
tests: Array
}
})
Here's where my inexperience with backend work comes into play. This setup doesn't really make sense to me. Say when I go and save a student, it will create a new student under the student collection in the database. This is not ideal, as the student should be stored in a way that is strictly accessible to the teacher who created it.
I was thinking about creating a new key in my Teachers Schema called "students"(which would be an array) that would push a student into it each time one was created.
It's definitely important that I plan this properly, as the teacher is going to have much more ability in the future, like creating assignments, grading students etc. I'd like to design this with best practices in mind, to ensure the teachers data is safe from other users.