CREATE TABLE usager(
nomUsager VARCHAR(20) PRIMARY KEY,
motDePasse VARCHAR(20) NOT NULL
);
CREATE TABLE motCle(
keyword VARCHAR(50) PRIMARY KEY
);
CREATE TABLE article(
id SMALLINT UNSIGNED PRIMARY KEY AUTO_INCREMENT,
titre VARCHAR(100),
texte TEXT,
nomUsager VARCHAR(20),
FOREIGN KEY (nomUsager) REFERENCES usager(nomUsager)
);
CREATE TABLE article_motsCle(
idArticle SMALLINT UNSIGNED,
keyword VARCHAR(50),
PRIMARY KEY (idArticle, keyword),
FOREIGN KEY (idArticle) REFERENCES article(id),
FOREIGN KEY (keyword) REFERENCES motCle(keyword)
);
所有的插入都起作用了,除了一个插入到article\u motscle表中
INSERT INTO article_motsCle VALUES
(1, "neutron stars");
出现错误#1452-无法添加或更新子行:外键约束失败。
暂无答案!
目前还没有任何答案,快来回答吧!