You would just assign the student to the class and not worry about the season. The season relationship would be through the Class class. HasManyThrough could be used to say find all students in Fall 19, which would be found from their relationship to class. The relationship to student would be defined on the Class class. Having a season class seems weird personally to me though. Would it not make more sense to have separate Class classes, with the dates they are running? Start/end etc.
Seasons, Classes, and Students - Trouble Setting This Up
So I'm trying to build an app for my wife's dance studio. For the part I'm currently stuck at I have 3 models:
- Seasons (Fall 2018, Summer 2019, Fall 2019, etc)
- Classes (Ballet, Tap, Jazz, Hip Hop, etc) //I know I can't name a model Classes, but for the sake of this post lets leave it as Classes
- Students (Lisa Simpson, Meg Griffin, etc)
So what I want to do is assign a Class to a Season. So I think this would be a Many-to-Many (a Class can belong to many Seasons, and a Season can have many Classes).
Then I want to enroll a Student into a Class. I believe this would also be a Many-to-Many (a Student takes many Classes, and a Class can have many Students).
The issue is, I want to enroll a Student into a Class that belongs to a particular Season. For example: 'Lisa' is enrolled in 'Ballet' in 'Fall 2018'. But Lisa does not get enrolled in Ballet in the 'Summer 2019' Season.
So I'm not sure how to set this up. Am I on the right track with them all being Many-to-Many relationships? If so how would I...
- Show all Students in a Class that belongs to a particular Season.
- Assign a Student to a Class that belongs to a particular Season.
Should this be done another way? I've heard about putting extra columns on pivot tables. Would that be better? If so how might I set that up? I've also heard of a Has-Many-Through relationship. Both of these are unfamiliar to me. But should I look into them? I just need some guidance on how to approach this and then I can try and do the learning from there. Thanks!
Please or to participate in this conversation.