Anda memiliki kunci primer komposit, jadi Anda memerlukan kunci asing komposit:
CREATE TABLE Prerequisite_to(
infs CHAR(4),
course_number CHAR(3),
PRIMARY KEY (infs,course_number),
FOREIGN KEY (infs, course_number) REFERENCES Class(infs, course_number)
);
Sebagai catatan, saya bukan penggemar kunci primer komposit. Saya juga berpikir prasyarat perlu dua referensi kursus. Jadi:
CREATE TABLE Classes (
class_id int auto_increment primary key,
infs CHAR(4) NOT NULL,
course_number CHAR(3) NOT NULL,
unique (infs, course_number)
);
CREATE TABLE Prerequisites (
preresequisite_id int auto_increment primary key,
class_id int,
prerequisite_class_id int,
FOREIGN KEY (class_id) REFERENCES Classes(class_id),
FOREIGN KEY (prerequisite_class_id) REFERENCES Classes(class_id)
);