我正在尝试在MySQL Workbench上设计数据库,但我不断收到此错误消息。我觉得这很可能是我的人际关系结构的问题,但我找不到差异。
以下是我收到的错误消息:
Executing SQL script in server
ERROR: Error 1215: Cannot add foreign key constraint
SQL Code:
-- -----------------------------------------------------
-- Table `bturpin`.`THREAD`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `bturpin`.`THREAD` (
`id` INT NOT NULL AUTO_INCREMENT,
`answer` DOUBLE NULL,
`comment` VARCHAR(255) NULL,
`test_subcategory_name` VARCHAR(45) NULL,
`RATING_id` INT NOT NULL,
`RATING_INSTRUCTOR_id` VARCHAR(30) NOT NULL,
`RATING_INSTRUCTOR_LESSON_title` VARCHAR(45) NOT NULL,
`RATING_INSTRUCTOR_LESSON_COURSE_num` VARCHAR(15) NOT NULL,
`RATING_RATER_id` VARCHAR(30) NOT NULL,
PRIMARY KEY (`id`, `RATING_id`, `RATING_INSTRUCTOR_id`, `RATING_INSTRUCTOR_LESSON_title`, `RATING_INSTRUCTOR_LESSON_COURSE_num`, `RATING_RATER_id`),
INDEX `fk_THREAD_RATING1_idx` (`RATING_id` ASC, `RATING_INSTRUCTOR_id` ASC, `RATING_INSTRUCTOR_LESSON_title` ASC, `RATING_INSTRUCTOR_LESSON_COURSE_num` ASC, `RATING_RATER_id` ASC),
CONSTRAINT `fk_THREAD_RATING1`
FOREIGN KEY (`RATING_id` , `RATING_INSTRUCTOR_id` , `RATING_INSTRUCTOR_LESSON_title` , `RATING_INSTRUCTOR_LESSON_COURSE_num` , `RATING_RATER_id`)
REFERENCES `bturpin`.`RATING` (`id` , `INSTRUCTOR_id` , `INSTRUCTOR_LESSON_title` , `INSTRUCTOR_LESSON_COURSE_num` , `RATER_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
SQL script execution finished: statements: 14 succeeded, 1 failed
Fetching back view definitions in final form.
Nothing to fetch
答案 0 :(得分:0)
尝试按此顺序转发:
您也可以考虑仅使用整数外键。
这似乎是MySQL Workbench在非整数键上使用外键的问题。