You have a composite primary key, so you need a composite foreign key:
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)
);
Just for the record, I'm not a fan of composite primary keys. I also think prerequisites need two course references. So:
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)
);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…