This is my first post and I'm a beginner developer and trying to develop a Science Fair management system for the School I work at and I'm having some trouble with entity mapping.
The idea is that the administrator of the Science Fair creates a GradeSystem to apply for that science fair edition with a set of grades. When a new ScienceFair edition is created, the user selects which GradeSystem they'll use. Then the user will register all students that'll participate in that Science Fair edition. The system must register all students grades in that edition based on a GradeSystem that was previously selected for that science fair edition.
What I'm thinking and needing some clues (sorry if I'm not being clear):
Should Grade be an entity? Or an embeddable class?
I'm thinking of creating an entity GradeSystem that'll have: id, Set<Grade>
grades
An entity ScienceFair that'll have a many to one relationship with GradeSystem entity (since one science fair edition can have only one grade system but a grade system can be used by many science fair edition).
An entity Student with id, name, class and a many to many relationship with ScienceFair. For this create an intermediate table with FK stud_id, FK science_fair_id and a List<Grade>
grades. But how can I relate this list of grades with the Class Grade since Grade class would already be related with GradeSystem.
I'm very confused and certainly misunderstanding some relational database concepts here. Any help will be very appreciated.
CodePudding user response:
You could model Grade as an entity or an enum, depending on how flexible the grades must be (always 1-5, always A-F, configurable by client?).
The relation of Student to Grade should imho be an entity like AchievedGrade, which contains his/her achieved Grade and the related ScienceFair and is a ManyToOne to Student.
ScienceFair and Grade itself are configuration data, and AchievedGrade is "running data".
I'd strongly recommend not to allow configurable grades, at least after the start of the ScienceFair, because this opens a can of worms regarding historizing entries.