Description:
If I design a model in MySQL Workbench with this structure
1:N 1:1
customer ------- cust_account ------- account
MySQL Workbench generates the script below, wich is "similar"
to that obtained with MySQL administrator backup option or
mysqldump --opt command.
But when I use the same script in the "import/Reverse
engineering..." option of MySQL Workbench, the connection
figure of the relationship 1:1 is changed to 1:N.
1:N 1:N
customer ------- cust_account ------- account
I want to specify a relation 1:N in a explicit way, usign
a table, cust_account in this case, and the logic is right
but the connection figure is wrong.
thanks for read.
How to repeat:
-- -----------------------------------------------------
-- SCRIPT FROM
-- MySQL Workbench 5.1.16 OSS Community edition
-- Revision 4210
-- -----------------------------------------------------
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='TRADITIONAL';
CREATE SCHEMA IF NOT EXISTS `banca` DEFAULT CHARACTER SET latin1 ;
USE `banca`;
-- -----------------------------------------------------
-- Table `banca`.`account`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `banca`.`account` (
`id_account` INT NOT NULL ,
`settlement` DECIMAL(9,2) NOT NULL ,
PRIMARY KEY (`id_account`) )
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `banca`.`customer`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `banca`.`customer` (
`id_customer` INT NOT NULL ,
`name` VARCHAR(45) NOT NULL ,
PRIMARY KEY (`id_customer`) )
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `banca`.`cust_account`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `banca`.`cust_account` (
`id_account` INT NOT NULL ,
`id_customer` INT NOT NULL ,
INDEX `fk_cust_account_customer1` (`id_customer` ASC) ,
PRIMARY KEY (`id_account`) ,
INDEX `fk_cust_account_account1` (`id_account` ASC) ,
CONSTRAINT `fk_cust_account_customer1`
FOREIGN KEY (`id_customer` )
REFERENCES `banca`.`customer` (`id_customer` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_cust_account_account1`
FOREIGN KEY (`id_account` )
REFERENCES `banca`.`account` (`id_account` )
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;