andershopl
andershopl

Reputation: 19

ER-diagram not displaying relationships in Datagrip

ER diagrams in datagrip won't display the relationsships between tables, only the tables. I'm using MYSQL. I've also tried to use MariaDB. enter image description here

Upvotes: 1

Views: 2807

Answers (1)

Guy Starbuck
Guy Starbuck

Reputation: 21873

Ok, I ran across this problem, and found that it may depend on how you declare the foreign keys at least using MySql.

The diagram does not display relationship for tables created using this syntax, with inline foreign key declaration:

CREATE TABLE table(
  my_pk int primary key,
  fkrow int references other_table(fkrefrow)
);

But the diagram DOES show relationship arrow if the table is created with this syntax, declaring the foreign key constraint on its own line:

CREATE TABLE table(
  my_pk int primary key,
  fkrow int not null,
  foreign key (fkrow) references other_table(fkrefrow)
)

Upvotes: 1

Related Questions