I’m getting the error below when I attempt to create a table with a couple foreign keys. It goes smoothly if I only include the userID foreign key, but complains when I try to get the other foreign key in there as well. What’s the deal?
ERROR 1005: Can't create table 'ps5_lwilkins.PhoneNumber' (errno: 150)
SQL Statement:
CREATE TABLE `ps5_lwilkins`.`PhoneNumber` (
`userID` CHAR(25) NOT NULL ,
`resumeID` CHAR(30) NOT NULL ,
`number` CHAR(45) NOT NULL ,
PRIMARY KEY (`userID`, `resumeID`, `number`) ,
INDEX `user_phoneNumber_fk1` (`userID` ASC) ,
INDEX `resume_phoneNumber_fk3` (`resumeID` ASC) ,
CONSTRAINT `user_phoneNumber_fk1`
FOREIGN KEY (`userID` )
REFERENCES `ps5_lwilkins`.`User` (`userID` )
ON DELETE CASCADE
ON UPDATE NO ACTION,
CONSTRAINT `resume_phoneNumber_fk3`
FOREIGN KEY (`resumeID` )
REFERENCES `ps5_lwilkins`.`Resume` (`resumeID` )
ON DELETE CASCADE
ON UPDATE NO ACTION)
ENGINE = InnoDB
Here’s the schema for User:
User(userid: CHAR(25), pass: VARCHAR(25)) userid is the PK
Here’s the schema for Resume:
Resume(userID: CHAR(25), resumeID: CHAR(30)
few other none important attributes). PK is (userID, resumeID).
Any ideas? Need more information?
Looking at other problems similar to this, I think it’s somehow a malformed FK on the resumeID… but I can’t see where!
I’ve tried several different names for the FK constraint btw.
EDIT: I don’t have the privilege to perform SHOW ENGINE INNODB STATUS
You’re on the right track with your comment above. You need to change this:
and this:
to this:
and this: