我想創建一個數據庫,但每次我試圖這樣做的時候,我得到錯誤信息外鍵約束:錯誤代碼:1215無法添加
1215 Cannot add foreign key constraint.
我整個上午一直在尋找解決方案但找不到任何有助於我的問題的東西,下面是我的代碼:
CREATE TABLE IF NOT EXISTS Lid (
lid_id INT(2) NOT NULL,
naam VARCHAR(45) NOT NULL,
email VARCHAR(45) NOT NULL,
tel_nummer VARCHAR(45) NOT NULL,
score INT(2) NOT NULL,
expertise VARCHAR(45) NOT NULL,
team_id INT(2) NOT NULL,
primary key (lid_id),
foreign key (team_id) references Team(team_id));
CREATE TABLE IF NOT EXISTS Team (
team_id INT(2) NOT NULL,
naam VARCHAR(45) NOT NULL,
score INT(2) NOT NULL,
captain INT(2) NOT NULL,
expertise VARCHAR(45) NOT NULL,
primary key (team_id),
foreign key (captain) references Lid(lid_id));
但球隊也有一個蓋子外鍵 – ysth