Это сценарий, который MySQL Workbench создает при форвард-инжиниринге:
-- MySQL Workbench Forward Engineering
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
-- -----------------------------------------------------
-- Schema DialogueFlowDB
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema DialogueFlowDB
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `DialogueFlowDB` DEFAULT CHARACTER SET utf8 ;
USE `DialogueFlowDB` ;
-- -----------------------------------------------------
-- Table `DialogueFlowDB`.`Status`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `DialogueFlowDB`.`Status` (
`ID` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`Status` CHAR(255) NOT NULL,
PRIMARY KEY (`ID`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `DialogueFlowDB`.`MultiStep_Dialogues`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `DialogueFlowDB`.`MultiStep_Dialogues` (
`ID` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`MultiStep_Dialogue` CHAR(255) NOT NULL,
`Data_Items` VARCHAR(1000) NULL,
`Nodes` VARCHAR(1000) NULL,
`Node_Links` VARCHAR(1000) NULL,
`Comments` VARCHAR(1000) NULL,
`Status` INT UNSIGNED NOT NULL,
`Issue` INT NOT NULL,
`LO_Name` CHAR(255) NULL,
`LO_Description` CHAR(255) NULL,
`LO_Condition` VARCHAR(1000) NULL,
`LO_Variables` VARCHAR(1000) NULL,
`LO_List` INT NULL,
PRIMARY KEY (`ID`),
INDEX `fk_MultiStep_Dialogues_Status1_idx` (`Status` ASC) VISIBLE,
CONSTRAINT `fk_MultiStep_Dialogues_Status1`
FOREIGN KEY (`Status`)
REFERENCES `DialogueFlowDB`.`Status` (`ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `DialogueFlowDB`.`Node_Types`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `DialogueFlowDB`.`Node_Types` (
`ID` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`Node_Type` CHAR(255) NOT NULL,
PRIMARY KEY (`ID`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `DialogueFlowDB`.`Variables`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `DialogueFlowDB`.`Variables` (
`ID` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`Variable` CHAR(255) NOT NULL,
`Variable_ID` CHAR(255) NOT NULL,
`System_Variable` CHAR(255) NULL,
`Values_per_Item` ENUM('Single', 'Multiple') NOT NULL DEFAULT 'Single',
`MultiStep_Dialogue` INT UNSIGNED NOT NULL,
`Input_Values` VARCHAR(1000) NULL,
`Comments` VARCHAR(1000) NULL,
PRIMARY KEY (`ID`),
INDEX `fk_Variables_MultiStep_Dialogues1_idx` (`MultiStep_Dialogue` ASC) VISIBLE,
CONSTRAINT `fk_Variables_MultiStep_Dialogues1`
FOREIGN KEY (`MultiStep_Dialogue`)
REFERENCES `DialogueFlowDB`.`MultiStep_Dialogues` (`ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `DialogueFlowDB`.`Nodes`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `DialogueFlowDB`.`Nodes` (
`ID` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`Node` CHAR(255) NOT NULL,
`Node_ID` CHAR(255) NOT NULL,
`Node_Sequence` ENUM('End', 'Middle', 'Start') NOT NULL,
`Node_Type` INT UNSIGNED NOT NULL,
`XPosition` INT NOT NULL DEFAULT 0,
`YPosition` INT NOT NULL DEFAULT 0,
`Answer` VARCHAR(1000) NOT NULL,
`Data_Item` INT UNSIGNED NULL,
`Status` INT UNSIGNED NOT NULL DEFAULT 'Created',
`MultiStep_Dialogue` INT UNSIGNED NOT NULL,
`Comments` VARCHAR(1000) NULL,
`Previous_Node_Links` VARCHAR(1000) NULL,
`Next_Node_Link` VARCHAR(100) NULL,
PRIMARY KEY (`ID`),
INDEX `fk_Nodes_MultiStep_Dialogues_idx` (`MultiStep_Dialogue` ASC) VISIBLE,
INDEX `fk_Nodes_Node_Types1_idx` (`Node_Type` ASC) VISIBLE,
INDEX `fk_Nodes_Variables1_idx` (`Data_Item` ASC) VISIBLE,
INDEX `fk_Nodes_Status1_idx` (`Status` ASC) VISIBLE,
CONSTRAINT `fk_Nodes_MultiStep_Dialogues`
FOREIGN KEY (`MultiStep_Dialogue`)
REFERENCES `DialogueFlowDB`.`MultiStep_Dialogues` (`ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Nodes_Node_Types1`
FOREIGN KEY (`Node_Type`)
REFERENCES `DialogueFlowDB`.`Node_Types` (`ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Nodes_Status1`
FOREIGN KEY (`Status`)
REFERENCES `DialogueFlowDB`.`Status` (`ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Nodes_Variables1`
FOREIGN KEY (`Data_Item`)
REFERENCES `DialogueFlowDB`.`Variables` (`ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `DialogueFlowDB`.`Node_Links`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `DialogueFlowDB`.`Node_Links` (
`ID` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`Node_Link` CHAR(255) NOT NULL,
`MultiStep_Dialogue` INT UNSIGNED NOT NULL,
`From_Node` INT UNSIGNED NOT NULL,
`To_Node` INT UNSIGNED NOT NULL,
`Status` INT UNSIGNED NOT NULL,
`Comments` VARCHAR(1000) NULL,
PRIMARY KEY (`ID`),
INDEX `fk_Node_Links_Nodes1_idx` (`From_Node` ASC) VISIBLE,
INDEX `fk_Node_Links_MultiStep_Dialogues1_idx` (`MultiStep_Dialogue` ASC) VISIBLE,
INDEX `fk_Node_Links_Nodes2_idx` (`To_Node` ASC) VISIBLE,
INDEX `fk_Node_Links_Status1_idx` (`Status` ASC) VISIBLE,
CONSTRAINT `fk_Node_Links_Nodes1`
FOREIGN KEY (`From_Node`)
REFERENCES `DialogueFlowDB`.`Nodes` (`ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Node_Links_MultiStep_Dialogues1`
FOREIGN KEY (`MultiStep_Dialogue`)
REFERENCES `DialogueFlowDB`.`MultiStep_Dialogues` (`ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Node_Links_Nodes2`
FOREIGN KEY (`To_Node`)
REFERENCES `DialogueFlowDB`.`Nodes` (`ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Node_Links_Status1`
FOREIGN KEY (`Status`)
REFERENCES `DialogueFlowDB`.`Status` (`ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
Это вывод:
Executing SQL script in server
ERROR: Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '
CONSTRAINT `fk_MultiStep_Dialogues_Status1`
FOREIGN KEY (`Status`)
RE' at line 19
SQL Code:
-- -----------------------------------------------------
-- Table `DialogueFlowDB`.`MultiStep_Dialogues`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `DialogueFlowDB`.`MultiStep_Dialogues` (
`ID` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`MultiStep_Dialogue` CHAR(255) NOT NULL,
`Data_Items` VARCHAR(1000) NULL,
`Nodes` VARCHAR(1000) NULL,
`Node_Links` VARCHAR(1000) NULL,
`Comments` VARCHAR(1000) NULL,
`Status` INT UNSIGNED NOT NULL,
`Issue` INT NOT NULL,
`LO_Name` CHAR(255) NULL,
`LO_Description` CHAR(255) NULL,
`LO_Condition` VARCHAR(1000) NULL,
`LO_Variables` VARCHAR(1000) NULL,
`LO_List` INT NULL,
PRIMARY KEY (`ID`),
INDEX `fk_MultiStep_Dialogues_Status1_idx` (`Status` ASC) VISIBLE,
CONSTRAINT `fk_MultiStep_Dialogues_Status1`
FOREIGN KEY (`Status`)
REFERENCES `DialogueFlowDB`.`Status` (`ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
SQL script execution finished: statements: 6 succeeded, 1 failed
Fetching back view definitions in final form.
Nothing to fetch
Я читаю онлайн, и проблема может быть в иностранных ключах(Хотя я проверил, и это кажется хорошим ...) или связано с объявлением engine = InnoDB.Я пытался использовать ответ в этом вопросе , но он не работал или я не совсем понял ответ (я поменял ENGINE = InnoDB; на ENGINE = InnoDB DEFAULT CHARSET = utf8 COLLATE = utf8_unicode_ci;) Я также проверил свою версию mysql, я использую 10.1.35-MariaDB, которая должна иметь доступные невидимые индексы (как упоминалось в другом ответе на вопрос, который я связал).
У меня нет опыта работы с MySQL, что таккогда-нибудь, так что извините, если это очень простая проблема.Спасибо за вашу помощь:)