Use additional tables for relation between two resources
At the moment it is only possible to link e.g. one teacher to a change. In reality there can be situations where you would like to assign multiple teachers to a change i.e. "Mrs. Miller's and Mr. Weber's classes are canceled today". With the current database structure you can only say "Mrs. Miller's class is canceled today" and "Mr. Weber's class is canceled today", i.e. you have to create two changes.
Eye detects that there are multiple changes with the same content excepting teachers and groups these changes. This is more of a dirty hack and Heart should handle these cases properly.
Therefore I suggest to drop the row
-
course
in_changes
-
subject
in_changes
-
teacher
in_changes
-
subject
in_courses
-
subject
in_teachers
and create the tables
_relation_change_course
change MEDIUMINT(8) NOT NULL,
course MEDIUMINT(8) NOT NULL,
CONSTRAINT uc_relation_change_course UNIQUE (change, course)
_relation_change_subject
change MEDIUMINT(8) NOT NULL,
subject MEDIUMINT(8) NOT NULL,
CONSTRAINT uc_relation_change_subject UNIQUE (change, subject)
_relation_change_teacher
change MEDIUMINT(8) NOT NULL,
teacher MEDIUMINT(8) NOT NULL,
CONSTRAINT uc_relation_change_teacher UNIQUE (change, teacher)
_relation_course_subject
course MEDIUMINT(8) NOT NULL,
subject MEDIUMINT(8) NOT NULL,
CONSTRAINT uc_relation_course_subject UNIQUE (course, subject)
_relation_teacher_subject
teacher MEDIUMINT(8) NOT NULL,
subject MEDIUMINT(8) NOT NULL,
CONSTRAINT uc_relation_teacher_subject UNIQUE (teacher, subject)
This change affects the API but does not make it incompatible with earlier versions, when we set e.g. the subject
property of teacher to 0
and introduce it as a new plural property i.e. subjects
.