Nested association in Domain Model?

0
Hi, Here is my problem statement: There are 3 entities: Student Subject Teacher   A student can be enrolled to multiple subjects A subject can have multiple teachers A teacher can teach multiple subjects While creating a new subject object, we can add the list of teachers objects who can teach that subject. Now, a student can choose his own subjects from the subjects added and for each subject, the student can choose the teacher(can also choose multiple teachers for same subject) from the list of teachers that teach that subject (this list of teachers was added while creating that subject). I am able to map different subjects objects to a student object but I am not able to map the corresponding teachers object to each student. This is what the domain model looks like: How can I map the corresponding teacher object to each student object based on the subject mapped to the student? Please let me know if you need more clarification. Thanks
asked
1 answers
1

Apparently, subject A given by teacher X is something else then subject A given by teacher Y. You need an extra entity:  intermediate entity SubjectGivenByTeacher. As soon as the teacher gets assigned to a subject, a new object gets added to SubjectGivenByTeacher. The student, first having chosen a subject, now also can choose a specific teacher for that subject.

 

answered