0
我有以下表結構&數據:插入到與外國約束的UUID列失敗
votes
表
season | episode | UUID | vote
1 | 1 | X-X-X-X | 1
1 | 1 | Y-Y-Y-Y | -1
users
表
UUID | name
X-X-X-X | Jon
Y-Y-Y-Y | Sam
Z-Z-Z-Z | Tim
在votes
表後,正在運行
ALTER TABLE votes ADD PRIMARY KEY (season, episode, UUID);
ALTER TABLE votes ADD INDEX (UUID);
ALTER TABLE votes ADD FOREIGN KEY (UUID) REFERENCES user (UUID)
ON DELETE CASCADE ON UPDATE CASCADE;
,並試圖插入這樣的條目:
season, episode, UUID, vote
1, 1, 'Z-Z-Z-Z', 1
到所述表,下面的錯誤跟我打招呼:
不能添加或更新子行,外鍵約束失敗(投票,約束`constraint_name`外鍵(UUID)參考文獻用戶(UUID)ON DELETE CASCADE ON UPDATE CASCADE)
我想保持連接到t的UUID他users
表,同時不允許同一季節多票 - 情節 - UUID組合,我怎麼能實現這一點?