Bug #77462 Template-created tables with PK(UQ) cause FK(UQ) inheritance
Submitted: 23 Jun 2015 20:17 Modified: 25 May 2018 13:46
Reporter: Peter Kingsbury Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Workbench: Modeling Severity:S3 (Non-critical)
Version:6.3.4.0 OS:Ubuntu (14.10 amd64)
Assigned to: CPU Architecture:Any
Tags: eed, erd, foreign key, templates, unique key, workbench

[23 Jun 2015 20:17] Peter Kingsbury
Description:
When forward-engineering tables created using Templates, enabling the PK and UQ flags for a column results in reference tables accessing this PK as a FK, cause the UQ flag to be 'inherited'. The result of this is that 1:n relationships cannot be established, since the FK column must contain unique values.

Further (possibly related0 the UQ flag is not reflected correctly in the Columns tab UI when inspecting a table's design properties.

How to repeat:
1) Create a template with an identifying (PK, UQ) column. Save.
2) Create two tables (t1, t2). 
3) Click the 1:n (identifying or non-identifying) button, click t1, then t2. A 1:n relationship is created, and a FK column and relation is created in t1.
4) Forward-engineer the database (generate inserts, drop objects before create, generate drop schema, omit schema qualifier, include model attached scripts).
5) On the 'Review SQL Script' tab, scroll down to the definition for t1.

Expected result:
In t1, the FK into t2 should not have a UNIQUE attribute assigned to it.

Actual result:
In t2, the FK into t2 has the UNIQUE attribute assigned to it. This prevents different records in t1 from referencing the same records in t2.

Suggested fix:
Prevent UNIQUE from being inherited from t1's PK.
[25 May 2018 13:46] Chiranjeevi Battula
Hello Peter Kingsbury,

Thank you for the bug report.
I could not repeat the issue at our end using MySQL Workbench 8.0.11.
If you can provide more information, please feel free to add it to this bug and change the status back to 'Open'.

Thank you for your interest in MySQL.

Thanks,
Chiranjeevi.