I have two tables Plane and PlaneType.
CREATE TABLE Plane
(
ID INT,
Maker VARCHAR(30),
Model VARCHAR(30),
LastMaint VARCHAR(30),
LastMaintA VARCHAR(3),
PRIMARY KEY (ID)
) ENGINE = INNODB;
CREATE TABLE PlaneType (
Maker VARCHAR(30),
Model VARCHAR(30),
PRIMARY KEY (Maker, Model)
) ENGINE = INNODB;
After I insert these two tables I add the following foreign and primary keys:
ALTER TABLE Plane ADD FOREIGN KEY (Maker) REFERENCES PlaneType(Maker);
ALTER TABLE Plane ADD FOREIGN KEY (Model) REFERENCES PlaneType(Model);
The first ALTER works perfectly but the second gives me the error:
ERROR 1005 (HY000): Can't create table '----.frm' (errno: 150)
I cannot figure out why the first ALTER works perfectly and the second doesn't. Both are references to primary keys, and that's the only issue I could think off. I'm a mysql noob so it might be something very obvious.
Any help is appreciated, thanks in advance.