Cannot add foreign key constraignt MySql

2019-07-23 12:54发布

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条回答
我命由我不由天
2楼-- · 2019-07-23 13:26

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)
)
查看更多
登录 后发表回答