Bug #60219 | defining a foreign key does not allow to check a none PK column in the src tb | ||
---|---|---|---|
Submitted: | 23 Feb 2011 9:36 | Modified: | 23 Feb 2011 18:30 |
Reporter: | Eitan Weisbeker | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Workbench: Modeling | Severity: | S2 (Serious) |
Version: | 5.2.31 | OS: | Windows (revision 7115) |
Assigned to: | CPU Architecture: | Any | |
Tags: | workbench;modeler;foreign key;fk; |
[23 Feb 2011 9:36]
Eitan Weisbeker
[23 Feb 2011 13:40]
Valeriy Kravchuk
Why do you think this is a bug? It is normal that foreign key may reference only UNIQUE key (and, thus, a primary key). Yes, it is possible for InnoDB table to have foreign key referencing some index columns, not primary key (read http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html), but this is still a kind of exception: "Deviation from SQL standards: A FOREIGN KEY constraint that references a non-UNIQUE key is not standard SQL. It is an InnoDB extension to standard SQL." Referencing just arbitrary column should not be supported, IMHO.
[23 Feb 2011 13:57]
Eitan Weisbeker
i mentioned that the problem is in selecting the columns of the source table. not the destination table were you would expect the column to be the PK. i want to reference source_table.regular_column to destination_table_pk_column. i can't select , using the workbench UI, any column i want, rather i am forced to choose the PK of the source table. see the section i wrote in "how to reproduce the problem".
[23 Feb 2011 14:20]
Valeriy Kravchuk
Then this is, probably, because their data types are different from data type of any PK in any table in the model. From the same manual page: "Corresponding columns in the foreign key and the referenced key must have similar internal data types inside InnoDB so that they can be compared without a type conversion. The size and sign of integer types must be the same. The length of string types need not be the same. For nonbinary (character) string columns, the character set and collation must be the same. "
[23 Feb 2011 15:36]
Eitan Weisbeker
my apologies, they indeed had data type mismatch. they were both BIGINT but the destination PK was marked with UnSigned and the source column was missing that indication. you can close the ticket\bug thx for the reponsiveness