MySQL Workbench – Relationships Between Tables Not Shown in Reverse Engineering (Mac OS)

foreign keyMySQLmysql-workbench

After running this and successfully creating the database, tables and both the primary and foreign keys, when I reverse engineer my database it won't show the relationships between tables. I'm using a MacBook Air(2017) Mojave 10.14.6, no dark mode and I've tried changing relationships notation from craw's foot to the others but still no luck.

create database test_asdf;
use test_asdf;

create table Department
(id int not null unique auto_increment primary key,
name varchar(30));

create table Professor
(id int not null unique auto_increment primary key,
name varchar(30),
adress varchar(50),
department_id int,
section_id int,
foreign key (department_id) references Department(id));

Now the thing is when I run the following the connections show:

create database test_asdf8;
use test_asdf8;

create table table1
(id int not null unique auto_increment primary key,
name varchar(30),
table2_id int);

create table table2
(id int not null unique auto_increment primary key,
name varchar(30),
new_id int,
foreign key (new_id) references table1(id));

left from first code sample, right from second code sample

Could someone please point out what I'm doing wrong here?

Best Answer

After further research it seems this is actually a bug.

Instead of directly reverse-engineering your database:

  • create a new model

  • save all your code in an .sql file

  • while in the model tab go to file-import-reverse engineer create script

  • check "place imported objects on diagram" and execute and there you go

Still unsure why the first above example won't work(with the straightforward approach) and the second one will but well... hope this helps.