Bug #46444 Unable to create Primary Keys containing multiple columns
Submitted: 29 Jul 2009 7:57 Modified: 29 Aug 2009 8:06
Reporter: Syed Mohammed Omer Farooq Email Updates:
Status: No Feedback Impact on me:
Category:MySQL Workbench Severity:S3 (Non-critical)
Version:5.1.16 OS:Microsoft Windows (SP3)
Assigned to: CPU Architecture:Any
Tags: Unable to create Primary Keys containing multiple columns

[29 Jul 2009 7:57] Syed Mohammed Omer Farooq
I am unable to define a primary key containing multiple columns in MySQL Workbench.

How to repeat:
Create a table in MySQL Workbench "customers". Define following columns:

Click the Index Tab and Define Index Name "PK_CUSTOMER" and from type columns select the Primary. From Index Columns select "BRANCH_CODE" and "CUSTOMER_ID" columns. As soon the multiple columns are selected the Type Column changed to INDEX.
[29 Jul 2009 8:06] Valeriy Kravchuk
Thank you for the problem report. Why not just to double click on "blue" dots to the left of column names at Columns tab, to make them look like a key? Please, check if this solves the problem of creating primary key on multiple columns.

Primary key in MySQL always has name PRIMARY... I think this is the reason for your problem.
[29 Aug 2009 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[29 Dec 2009 5:19] [ name withheld ]
This bug still exists in MWB 5.2.11. However, the bug is technically not that MWB *cannot* create compound primary keys. The suggested workaround ("double click on blue dots to the left of column names at Columns tab, to make them look like a key") does work. Rather, the bug is that the Indexes tab of the MWB table editor has a drop-down for Index Type, and the PRIMARY option in that drop-down does not make the selected index the primary key.

My proposal for fixing this bug:
- either remove PRIMARY from the Index Type drop-down
- or, if PRIMARY is selected from the drop-down, and if the index satisfies the requirements for a primary key (i.e., contains only NOT NULL columns), then rename the index to PRIMARY (as that's the only valid name for a primary key), and change the index type to PRIMARY. Note that if the index fails to satisfy the requirements for a primary key, then the reason for the failure must be communicated to the user.