I am creating a database in MySQL for school. It has come up with the error 'cannot add foreign key constraint.' I have looked at other similar questions but cannot find out how it relates to my table. Please help!
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Update your entries
table like so:
CREATE TABLE IF NOT EXISTS entries(
entry_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
exam_date DATE NOT NULL,
student_id INT REFERENCES students(student_id),
subject_id INT REFERENCES subjects(subject_id),
PRIMARY KEY(entry_id)
)