Say I have three entities(or tables): School
, Student
and Classroom
. How do I ensure a Student
belongs to a Classroom
which belongs to the same School
the Student
belongs to? Considering a Student
may not be part of any Classroom.
I'm facing that problem in many other ways. For example, when I add the entity Teacher
. How can I guarantee at database level that a Teacher
teaches on a Classroom
of the same School
the Teacher
belongs to? And so on...