Re: Error 3734
This is the complete creation script :
-- 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 mydb
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema mydb
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `mydb` DEFAULT CHARACTER SET utf8 ;
USE `mydb` ;
-- -----------------------------------------------------
-- Table `mydb`.`Categoria`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Categoria` (
`Id` INT NOT NULL,
`IdParent` INT NULL,
`Livello` INT NULL,
`Nome` VARCHAR(45) NULL,
`Descrizione` VARCHAR(45) NULL,
INDEX `fk_Categoria_Categoria1_idx` (`IdParent` ASC) VISIBLE,
CONSTRAINT `fk_Categoria_Categoria1`
FOREIGN KEY (`IdParent`)
REFERENCES `mydb`.`Categoria` (`Id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`Brand`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Brand` (
`id` INT NOT NULL,
`Nome` VARCHAR(45) NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`Genere`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Genere` (
`Id` INT NOT NULL,
`IdParent` INT NULL,
`Nome` VARCHAR(45) NULL,
INDEX `fk_Genere_Genere1_idx` (`IdParent` ASC) VISIBLE,
CONSTRAINT `fk_Genere_Genere1`
FOREIGN KEY (`IdParent`)
REFERENCES `mydb`.`Genere` (`Id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`Articolo`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Articolo` (
`idArticolo` INT NOT NULL,
`IdCategoria` INT NOT NULL,
`IdBrand` INT NOT NULL,
`IdGenere` INT NULL,
`Nome` VARCHAR(45) NULL,
`Descrizione` VARCHAR(45) NULL,
`CodiceComm` VARCHAR(45) NULL,
`DataInserimento` DATETIME NULL,
PRIMARY KEY (`idArticolo`, `IdCategoria`, `IdBrand`),
INDEX `fk_Articolo_Categoria1_idx` (`IdCategoria` ASC) VISIBLE,
INDEX `fk_Articolo_Brand1_idx` (`IdBrand` ASC) VISIBLE,
INDEX `fk_Articolo_Genere1_idx` (`IdGenere` ASC) VISIBLE,
CONSTRAINT `fk_Articolo_Categoria1`
FOREIGN KEY (`IdCategoria`)
REFERENCES `mydb`.`Categoria` (`Id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Articolo_Brand1`
FOREIGN KEY (`IdBrand`)
REFERENCES `mydb`.`Brand` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Articolo_Genere1`
FOREIGN KEY (`IdGenere`)
REFERENCES `mydb`.`Genere` (`Id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`Azienda`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Azienda` (
`Id` INT NOT NULL,
`Nome` VARCHAR(45) NULL,
PRIMARY KEY (`Id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`Azienda_has_Articolo`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Azienda_has_Articolo` (
`Azienda_Id` INT NOT NULL,
`Articolo_idArticolo` INT NOT NULL,
`Articolo_IdCategoria` INT NOT NULL,
`Articolo_IdBrand` INT NOT NULL,
PRIMARY KEY (`Azienda_Id`, `Articolo_idArticolo`, `Articolo_IdCategoria`, `Articolo_IdBrand`),
INDEX `fk_Azienda_has_Articolo_Articolo1_idx` (`Articolo_idArticolo` ASC, `Articolo_IdCategoria` ASC, `Articolo_IdBrand` ASC) VISIBLE,
INDEX `fk_Azienda_has_Articolo_Azienda_idx` (`Azienda_Id` ASC) VISIBLE,
CONSTRAINT `fk_Azienda_has_Articolo_Azienda`
FOREIGN KEY (`Azienda_Id`)
REFERENCES `mydb`.`Azienda` (`Id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Azienda_has_Articolo_Articolo1`
FOREIGN KEY (`Articolo_idArticolo` , `Articolo_IdCategoria` , `Articolo_IdBrand`)
REFERENCES `mydb`.`Articolo` (`idArticolo` , `IdCategoria` , `IdBrand`)
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;