我正在尝试对我所做的erd进行正向工程,但是正向工程过程将我作为输出给出一个错误。 ERROR: Error 3734: Failed to add the foreign key constraint. Missing column 'straatid' for constraint 'verzinzelf3' in the referenced table 'locatie'
.
但这很奇怪,因为列名 straatid
事实上在table上 Locatie
. 表与表之间的关系 Team
以及 Locatie
与 Locatie
以及 Plant
,但似乎我只得到了表的关系之间的一个错误 Locatie
以及 Plant
. 我真的不知道怎么解决这个错误。有人能帮我解决这个问题吗?。
这是对应该执行的sql脚本的检查:
-- MySQL Workbench Forward Engineering
CREATE SCHEMA IF NOT EXISTS `mydb` DEFAULT CHARACTER SET utf8 ;
USE `mydb` ;
-- -----------------------------------------------------
-- Table `mydb`.`table1`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`table1` (
`StraatID` VARCHAR(45) NOT NULL,
`Straat` VARCHAR(45) NULL,
`Latitude` VARCHAR(45) NULL,
`Longitude` VARCHAR(45) NULL,
PRIMARY KEY (`StraatID`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`Locatie`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Locatie` (
`Huisnr` VARCHAR(45) NOT NULL,
`StraatID` VARCHAR(45) NOT NULL,
`Toevoeging` VARCHAR(45) NULL,
PRIMARY KEY (`Huisnr`, `StraatID`),
UNIQUE INDEX `StraatID_UNIQUE` (`StraatID` ASC) VISIBLE,
UNIQUE INDEX `Huisnr_UNIQUE` (`Huisnr` ASC) VISIBLE,
INDEX `verzinzelf2_idx` (`StraatID` ASC) VISIBLE,
CONSTRAINT `verzinzelf2`
FOREIGN KEY (`StraatID`)
REFERENCES `mydb`.`table1` (`StraatID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`Team`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Team` (
`Teamnr` INT NOT NULL,
`StraatID` VARCHAR(45) NOT NULL,
`Huisnr` VARCHAR(45) NOT NULL,
`StraatID1` VARCHAR(45) NOT NULL,
PRIMARY KEY (`Teamnr`),
INDEX `verzinzelf5_idx` (`Huisnr` ASC, `StraatID1` ASC) VISIBLE,
CONSTRAINT `verzinzelf5`
FOREIGN KEY (`Huisnr` , `StraatID1`)
REFERENCES `mydb`.`Locatie` (`Huisnr` , `StraatID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`Eigenaar`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Eigenaar` (
`Eigenaar` INT NOT NULL,
PRIMARY KEY (`Eigenaar`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`Plant`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Plant` (
`Plant beschrijving` VARCHAR(45) NOT NULL,
`Kaartlokatie` VARCHAR(45) NOT NULL,
`Oppervlakte` VARCHAR(45) NOT NULL,
`Eigenaar` INT NOT NULL,
`Huisnr` VARCHAR(45) NOT NULL,
`StraatID` VARCHAR(45) NOT NULL,
PRIMARY KEY (`Plant beschrijving`, `Kaartlokatie`, `Oppervlakte`),
INDEX `verzinzelf4_idx` (`Eigenaar` ASC) VISIBLE,
INDEX `verzinzelf3_idx` (`Huisnr` ASC, `StraatID` ASC) VISIBLE,
CONSTRAINT `verzinzelf4`
FOREIGN KEY (`Eigenaar`)
REFERENCES `mydb`.`Eigenaar` (`Eigenaar`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `verzinzelf3`
FOREIGN KEY (`Huisnr` , `StraatID`)
REFERENCES `mydb`.`Locatie` (`Huisnr` , `StraatID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`Meting`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Meting` (
`Teamnr` INT NOT NULL,
`Plant` VARCHAR(45) NOT NULL,
`Meetsoort` VARCHAR(45) NULL,
PRIMARY KEY (`Teamnr`, `Plant`),
INDEX `verzinzelf1_idx` (`Plant` ASC) VISIBLE,
INDEX `verzinzelf_idx` (`Teamnr` ASC) VISIBLE,
CONSTRAINT `verzinzelf`
FOREIGN KEY (`Teamnr`)
REFERENCES `mydb`.`Team` (`Teamnr`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `verzinzelf1`
FOREIGN KEY (`Plant`)
REFERENCES `mydb`.`Plant` (`Plant beschrijving`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
以及完整的错误消息:
Executing SQL script in server
ERROR: Error 3734: Failed to add the foreign key constraint. Missing column 'straatid' for constraint 'verzinzelf3' in the referenced table 'locatie'
SQL Code:
-- -----------------------------------------------------
-- Table `mydb`.`Plant`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Plant` (
`Plant beschrijving` VARCHAR(45) NOT NULL,
`Kaartlokatie` VARCHAR(45) NOT NULL,
`Oppervlakte` VARCHAR(45) NOT NULL,
`Eigenaar` INT NOT NULL,
`Huisnr` VARCHAR(45) NOT NULL,
`StraatID` VARCHAR(45) NOT NULL,
PRIMARY KEY (`Plant beschrijving`, `Kaartlokatie`, `Oppervlakte`),
INDEX `verzinzelf4_idx` (`Eigenaar` ASC) VISIBLE,
INDEX `verzinzelf3_idx` (`Huisnr` ASC, `StraatID` ASC) VISIBLE,
CONSTRAINT `verzinzelf4`
FOREIGN KEY (`Eigenaar`)
REFERENCES `mydb`.`Eigenaar` (`Eigenaar`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `verzinzelf3`
FOREIGN KEY (`Huisnr` , `StraatID`)
REFERENCES `mydb`.`Locatie` (`Huisnr` , `StraatID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
SQL script execution finished: statements: 9 succeeded, 1 failed
Fetching back view definitions in final form.
Nothing to fetch
暂无答案!
目前还没有任何答案,快来回答吧!