Consider the following situation: students receive grades for different topics, where n-th-year students only attend courses covering n-th-year topics. So, we get a commutative “belongs-to” square:
Grades -----> Students
| |
| |
v v
Topics -----> Levels
This is what I mean by “multi-path” in the subject.
(1) What is the technical term for this sort of constraint?
Now add the following data: the topics are grouped into subjects, and there are further data X attached to certain pairs (student, subject), so X is essentially a subset of the cartesian product Students x Subjects. Now the following fact (F) is known: grades always correspond to pairs (student, subject) having a record in X, so we can lift the student foreign keys in the table grades to foreign keys referencing X:
Grades -------> X -------> Students
| |
| |
v v
Topics ----> Subjects
introducing another multi-path constraint (but on the other hand ensuring condition (F)).
(2) What is the theoretical view on these things?
If this is too vague, let me restrict it to the following:
(2′) What is the preferred design: the “disjoint” way such that the table grades has foreign keys for students and topics, or the “tight” way of referring to closer table X at the cost of introducing the constaint?
Actually, for the moment I am content with the solution given in How to provide constraint to an associative table relating to two source tables with a common foreign key?
Summary: add a column level_id to Grades and have multi-column foreign keys (topic_id, level_id) and (student_id, level_id) referencing Topic and Student, respectively.