why the foreign key gives my headache?
first i created database names colorcode
then paper
table which works fine:
CREATE TABLE paper (
paper_id int(20) NOT NULL,
description VARCHAR(40) NOT NULL,
paper_color VARCHAR(40) NOT NULL,
PRIMARY KEY (paper_id, paper_color)
) ENGINE=InnoDB;
then brick
table
CREATE TABLE brick(
brick_id int(20) NOT NULL,
description varchar(40) NOT NULL,
brick_color varchar (40) NOT NULL,
PRIMARY KEY (brick_id),
FOREIGN KEY (brick_color) REFERENCES paper(paper_color)
) ENGINE=InnoDB;
which doesn't=>
#1005 - Can't create table 'colorcode.brick' (errno: 150)
thank you for your help
Create a separate key for
paper_color
and it will work: