Bug #55083 Failed to create foreign key if size of the integer value doesn't mach
Submitted: 8 Jul 2010 14:07 Modified: 7 Oct 2011 6:04
Reporter: Andrei Frolov Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Workbench: Modeling Severity:S2 (Serious)
Version:5.2.25 CE OS:Windows
Assigned to: CPU Architecture:Any
Tags: foreign key, modeling, value size

[8 Jul 2010 14:07] Andrei Frolov
Description:
In EER model it's impossible to create foreign key if size of the INT doesn't match.

How to repeat:
In EER diagram create 2 tables:
'table1': ID INT(5) Primary key, Not null;
'table2': IDTable1 INT

Double click 'table2', in table properties tab goto 'Foreign key' sub tab, in the left table enter foreign key name 'fk1', select 'mydb'.'table1' as 'referenced table'. In the right table 'referenced column' combobox for 'IDTable1' column is empty.

Suggested fix:
Size of the INT must match. i.e. change type of the 'table2'.'IDTable1' from INT to INT(5), or 'table1'.'ID' from INT(5) to INT.
[8 Jul 2010 16:56] Valeriy Kravchuk
The idea to change data type to match PK when adding FK with the type that differs in size sounds like a reasonable feature request.
[9 Jul 2010 0:34] Andrei Frolov
Please note that INT type (size is not specified) during database export or synchronization is written to database as INT(11), but imported as INT(11). So imported model becomes incompatible with exported one in the context of this bug report.
[7 Oct 2011 6:04] Philip Olson
Fixed as of 5.2.26:

+        When using the &workbench; table properties to add a foreign
+        key, the size of a new foreign key field will now update to
+        match the size of the corresponding primary key.