I have a web application that uses Firestore as a database. It helps teachers manage classes, students, and lessons. When a teacher logs into the app, they can select one of the classes they are in charge of. After selecting a class, they can choose one of the students from that class. Once a student is selected, the teacher can see a list of lessons the student participated in within a day or a month.
Current Database Structure
I have a few collections:
University id: string name: string
Class id: string classId: string name: string
Student id: string classId: string name: string
Lesson (as a subcollection of Class) id: string classId: string studentId: string executedOn: number
But I run into a problem where a student can move between classes, making it difficult to query the lessons they participated in.
I decided to restructure my database by moving the subcollection “Lesson” to either a subcollection of students or a separate collection.
I think moving the subcollection “Lesson” to a separate collection would be a better choice as the app scales, but I am wondering if there is any potential downside to this approach. Please give me advice?