看了两天,不知道这是什么意思。我知道它的意思是“正如它所说的那样”,但我不知道如何解决它。有人可以用外行的方式向我解释并帮助我吗?
ERROR: Error 1452: Cannot add or update a child row: a foreign key constraint fails
(`sls11n`.`dependent`, CONSTRAINT `fk_dependent_employee1` FOREIGN KEY (`emp_id`)
REFERENCES `employee` (`emp_id`) ON DELETE NO ACTION ON UPDATE NO ACTION)
INSERT INTO `sls11n`.`dependent` (`dep_id`, `emp_id`, `dep_ssn`, `dep_fname`, `dep_lname`,
`dep_street`, `dep_city`, `dep_state`, `dep_zip`, `dep_phone`, `dep_email`, `dep_notes`)
VALUES (NULL, 13, 123456789, 'Gary', 'Hart', 'West St', 'San Diego', 'CA', '23424',
'1234567890', 'garyhart@me.com', NULL)
这是我认为相关的脚本:
-- -----------------------------------------------------
-- Table `sls11n`.`employee`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `sls11n`.`employee` ;
SHOW WARNINGS;
CREATE TABLE IF NOT EXISTS `sls11n`.`employee` (
`emp_id` TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,
`emp_ssn` INT UNSIGNED NOT NULL,
`emp_fname` VARCHAR(15) NOT NULL,
`emp_lname` VARCHAR(20) NOT NULL,
`emp_street` VARCHAR(45) NOT NULL,
`emp_city` VARCHAR(45) NOT NULL,
`emp_state` CHAR(2) NOT NULL,
`emp_zip` CHAR(9) NOT NULL,
`emp_phone` CHAR(15) NOT NULL,
`emp_email` VARCHAR(100) NOT NULL,
`emp_doh` DATE NOT NULL,
`emp_is_inspect` ENUM('y', 'n') NOT NULL,
`emp_notes` VARCHAR(250) NULL,
PRIMARY KEY (`emp_id`))
ENGINE = InnoDB;
SHOW WARNINGS;
-- -----------------------------------------------------
-- Table `sls11n`.`dependent`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `sls11n`.`dependent` ;
SHOW WARNINGS;
CREATE TABLE IF NOT EXISTS `sls11n`.`dependent` (
`dep_id` TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,
`emp_id` TINYINT UNSIGNED NOT NULL,
`dep_ssn` INT UNSIGNED NOT NULL,
`dep_fname` VARCHAR(45) NOT NULL,
`dep_lname` VARCHAR(45) NOT NULL,
`dep_street` VARCHAR(45) NOT NULL,
`dep_city` VARCHAR(45) NOT NULL,
`dep_state` CHAR(2) NOT NULL,
`dep_zip` CHAR(9) NOT NULL,
`dep_phone` CHAR(10) NOT NULL,
`dep_email` VARCHAR(100) NOT NULL,
`dep_notes` VARCHAR(250) NULL,
PRIMARY KEY (`dep_id`),
INDEX `fk_dependent_employee1_idx` (`emp_id` ASC),
CONSTRAINT `fk_dependent_employee1`
FOREIGN KEY (`emp_id`)
REFERENCES `sls11n`.`employee` (`emp_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
有人有想法么?请使用简单的术语,当我说我不明白时,我不是在开玩笑。