Bug #26821 can't create a good "many to many" relation script
Submitted: 3 Mar 2007 10:00 Modified: 5 Mar 2007 11:20
Reporter: Shaman Shaman Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Workbench Preview Severity:S2 (Serious)
Version:1.1.9 alpha OS:Windows (Win xp / Linux)
Assigned to: CPU Architecture:Any
Tags: foreign key, generated script, many to many

[3 Mar 2007 10:00] Shaman Shaman
Description:

Can't generate a good "many to many" relation script to create the linking table.
The foreign key are not well managed.

How to repeat:
1 ) create 2 tables with a relation "many to many"
2) synchronise with database
3) the script is not a good one, the type of the FK is missing

the workaround consist in modify the script.

Suggested fix:
fix : 
Modifify the script 
original generated script (linking table part only):
===================================================

CREATE TABLE `test`.`PERSON_has_ADRESS` (
  `FKPERSONpersonID` NOT NULL,                   <-------- here
  `FKADRESSadressID` NOT NULL,                   <-------- here
  CONSTRAINT `FKPERSON` FOREIGN KEY `FKPERSON` (`FKPERSONpersonID`)
    REFERENCES `test`.`PERSON` (`personID`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `FKADRESS` FOREIGN KEY `FKADRESS` (`FKADRESSadressID`)
    REFERENCES `test`.`ADRESS` (`adressID`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION
)
ENGINE = InnoDB;

Fixed script :
===============

CREATE TABLE `test`.`PERSON_has_ADRESS` (
  `FKPERSONpersonID` INT UNSIGNED UNSIGNED NOT NULL,      <-------- here
  `FKADRESSadressID` INT UNSIGNED UNSIGNED NOT NULL,      <-------- here
  CONSTRAINT `FKPERSON` FOREIGN KEY `FKPERSON` (`FKPERSONpersonID`)
    REFERENCES `test`.`PERSON` (`personID`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `FKADRESS` FOREIGN KEY `FKADRESS` (`FKADRESSadressID`)
    REFERENCES `test`.`ADRESS` (`adressID`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION
)
ENGINE = InnoDB;
[5 Mar 2007 11:20] MySQL Verification Team
Thank you for the bug report.
[5 Mar 2007 11:21] MySQL Verification Team
Thank you for the bug report.