fake relationships in DataGrip

431 Views Asked by At

I'm trying to create an ER diagram with DataGrip 2019.3 however I get duplication of relationships. Once a "false" relay is only based on keys (t1_id:t1 id) without any foreign keys being set at all, and after creating a foreign key the relation is already duplicated (id:t2_id_fkey id).

I'm using PostgreSQL 12

CREATE TABLE public.t1
(
    id integer NOT NULL,
    name character varying COLLATE pg_catalog."default",
    CONSTRAINT t1_pkey PRIMARY KEY (id)
)

CREATE TABLE public.t2
(
    id integer NOT NULL,
    t1_id integer NOT NULL,
    namne character varying COLLATE pg_catalog."default",
    CONSTRAINT t2_pkey PRIMARY KEY (id),
    CONSTRAINT t2_id_fkey FOREIGN KEY (id)
        REFERENCES public.t1 (id) MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION
)

ER diagram

1

There are 1 best solutions below

1
On

In DataGrip 2019.3 the 'fake keys' were introduced. More information is here: https://www.jetbrains.com/help/datagrip/columns.html#foreign-keys

In your case I see two problems.

  1. Fake keys shouldn't be displayed on the diagram by default (but they can be useful). So we will introduce the setting.
  2. Fake keys should disappear from the diagram when the real one is created. We will fix this as well.

So, expect all this in the nearest update. Thanks!