Bug #93332 foreign key referencing 2 columns does not show up in schemas
Submitted: 25 Nov 2018 18:22 Modified: 26 Nov 2018 9:07
Reporter: Thomas Locke Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Workbench Severity:S3 (Non-critical)
Version:8.0.13 OS:Windows (Microsoft Windows 10 Pro)
Assigned to: CPU Architecture:Any
Tags: WBBugReporter

[25 Nov 2018 18:22] Thomas Locke
Description:
After creating a new table with this:
create table core_mony
(
    sys_key int unsigned not null,
    mony_key int unsigned not null,
    mony_type char(1) not null,

    primary key(mony_key, sys_key),

    constraint
    foreign key(sys_key)
    references system_sys(sys_key),

    constraint
    foreign key(mony_key, mony_type)
    references system_mony(mony_key, mony_type)
);

And refreshing the schemas it only shows core_mony_ibfk_1 in foreign keys of core_mony. The second foreign key (core_mony_ibfk_2) does not show up.

show create table core_mony shows this:

CREATE TABLE `core_mony` (
   `sys_key` int(10) unsigned NOT NULL,
   `mony_key` int(10) unsigned NOT NULL,
   `mony_type` char(1) NOT NULL,
   PRIMARY KEY (`mony_key`,`sys_key`),
   KEY `sys_key` (`sys_key`),
   KEY `mony_key` (`mony_key`,`mony_type`),
   CONSTRAINT `core_mony_ibfk_1` FOREIGN KEY (`sys_key`) REFERENCES `system_sys` (`sys_key`),
   CONSTRAINT `core_mony_ibfk_2` FOREIGN KEY (`mony_key`, `mony_type`) REFERENCES `system_mony` (`mony_key`, `mony_type`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci

How to repeat:
drop database test;
create database test;
use test;

create table system_sys
(
    sys_key int unsigned not null auto_increment,
    sys_code char(3) not null,
    sys_desc char(40) not null,
    sys_type char(1) not null,
    sys_rcpt_no int not null,

    primary key(sys_key),
    unique index(sys_code),
    unique index(sys_desc)
);

create table system_mony
(
    mony_key int unsigned not null auto_increment,
    mony_type char(1) not null,entry,
    mony_code char(3) not null,
    mony_desc char(40) not null,
    
    primary key(mony_key),
    unique index(mony_key, mony_type),
    unique index(mony_code),
    unique index(mony_desc)
);

create table core_mony
(
    sys_key int unsigned not null,
    mony_key int unsigned not null,
    mony_type char(1) not null,

    primary key(mony_key, sys_key),

    constraint
    foreign key(sys_key)
    references system_sys(sys_key),

    constraint
    foreign key(mony_key, mony_type)
    references system_mony(mony_key, mony_type)
);

Suggested fix:
Make the foreign key show up in schemas.
[26 Nov 2018 9:07] MySQL Verification Team
Thank you for the bug report.