I have been looking into many posts here and other places but I still can’t make it work.
I’m trying to create the following 2 tables on xampp. But I’m having problems in the second with the foreign key, even after added the InnoDB.
Can anyone take a look at the following code and tell me what am i doing wrong in the foreign key part so that xampp doesn’t accept the table? Thank you!
CREATE TABLE fichas (
id_ficha INT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE,
cod_produto VARCHAR(20) NULL,
nome_produto VARCHAR(50),
versao INT,
data_ficha DATE,
PRIMARY KEY (id_ficha)
) ENGINE=INNODB;
CREATE TABLE ident_dangers (
id_fichas INT NOT NULL,
class_subst TEXT NULL,
simb_perigo VARCHAR(50) NULL,
words_r VARCHAR (200) NULL,
INDEX (id_fichas),
FOREIGN KEY (id_fichas) REFERENCES fichas(id_ficha),
) ENGINE = InnoDB;
I have faced similar error. Usually it comes from having different types on your fields.
Your table
fichashas:To match it your field
id_dichason theident_dangerstables should be declared: