Foreign Keys in SQL
Only students listed in the Students relation should be allowed to enroll for courses.
CREATE TABLE Enrolled
(sid CHAR(20), cid CHAR(20), grade CHAR(2),
PRIMARY KEY (sid,cid),
FOREIGN KEY (sid) REFERENCES Students )
Enrolled
Students
Previous slide
Next slide
Back to first slide
View graphic version