If I understand you correctly, you're saying that your Section table has a primary key of (sectionNo,semester,courseID), and that there can thus be multiple records with the same sectionNo and semester? And then you want to connect Registration, which does not have a courseID, to this table? To the best of my knowledge you can't use a "references" clause because it will not link to a unique identifier. But that doesn't stop you from writing queries that join the two tables.
Update
Of course there are many possible queries depending on what it is you want to know. If, say, you want to know all the classes that student #17 has ever registered for, you could write:
select section.sectionno, section.semester, section.courseid
from registration
join section on section.sectionno=registration.sectionno
and section.semester=registration.semester
where studentid=17
If you want all the courses for a given Registration record:
select coursed
from registration
join section on section.sectionno=registration.sectionno
and section.semester=registration.semester
where registration.sectionno=@section
and registration.semester=@semester
and registration.studentid=@student
Now, hmm, writing that query this indicates to me that a student registers for all the courses making up a section and semester. Is this true? If there are multiple courses in a section and semester, does the student sign up for all of them at one time, or does he pick individual ones? If he picks, then it would seem that Registration needs to specify which course.
I don't know what "section" means here so I don't know how it relates.
Section(SectionNo, ...
deviates from the convention of the other tables. EitherSectionNo
is itself a Primary Key (surrogate or natural), or it is just associated information with a key of(Semester, CourseID)
, or it is part of a composite key. Depending on which of the 3 is correct, your foreign key inRegistration
toSection
must be adjusted to align with the Section primary key. As it stands, you will need to addCourseID
toRegistration
and add it in the foreign key to Section. – StuartLC