Web forum is in read-only mode. Login as active registered customer for write access
  Forum Search   New Posts New Posts

PostgreSQL FKs with same name

 Post Reply Post Reply
Author
Sant'Anna Alexandre View Drop Down
New Member
New Member
Avatar

Joined: 13 Mar 2018
Posts: 7
Post Options Post Options   Quote Sant'Anna Alexandre Quote  Post ReplyReply Direct Link To This Post Topic: PostgreSQL FKs with same name
    Posted: 28 Nov 2018 at 6:09am
PostgreSQL allow me use same FK names for different objects.

But when I import from database, the FKs with same names are grouped in the interface and when I try to access them, I'm receiving access violations.

Is there any plans to solve it or there is a workaround?

Some samples:

-- Table 1
CREATE TABLE modelo.pessoa_contato (
  id SERIAL,
  id_pessoa INTEGER NOT NULL,
  nome VARCHAR(100),
  email VARCHAR(100),
  telefone VARCHAR(20),
  ativo public.ativo NOT NULL,
  incluido DATE DEFAULT CURRENT_DATE NOT NULL,
  id_usu_inclusao INTEGER NOT NULL,
  alterado DATE,
  id_usu_alteracao INTEGER,
  CONSTRAINT pessoa_contato_pkey PRIMARY KEY(id),
  CONSTRAINT contatos FOREIGN KEY (id_pessoa)
    REFERENCES modelo.pessoa(id)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION
    NOT DEFERRABLE,
  CONSTRAINT usuario_alteracao FOREIGN KEY (id_usu_alteracao)
    REFERENCES controle.usuario(id)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION
    NOT DEFERRABLE,
  CONSTRAINT usuario_inclusao FOREIGN KEY (id_usu_inclusao)
    REFERENCES controle.usuario(id)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION
    NOT DEFERRABLE
) WITH (oids = false);

-- Table 2
CREATE TABLE modelo.pessoa_endereco (
  id SERIAL,
  id_pessoa INTEGER NOT NULL,
  tipo CHAR(1) NOT NULL,
  cep VARCHAR(8) NOT NULL,
  logradouro VARCHAR(100) NOT NULL,
  numero VARCHAR(20),
  complemento VARCHAR(20),
  bairro VARCHAR(50),
  cidade VARCHAR(50),
  estado VARCHAR(2),
  pais VARCHAR(50),
  ativo public.ativo NOT NULL,
  incluido DATE DEFAULT CURRENT_DATE NOT NULL,
  id_usu_inclusao INTEGER NOT NULL,
  alterado DATE,
  id_usu_alteracao INTEGER,
  CONSTRAINT pessoa_endereco_pkey PRIMARY KEY(id),
  CONSTRAINT enderecos FOREIGN KEY (id_pessoa)
    REFERENCES modelo.pessoa(id)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION
    NOT DEFERRABLE,
  CONSTRAINT usuario_alteracao FOREIGN KEY (id_usu_alteracao)
    REFERENCES controle.usuario(id)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION
    NOT DEFERRABLE,
  CONSTRAINT usuario_inclusao FOREIGN KEY (id_usu_inclusao)
    REFERENCES controle.usuario(id)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION
    NOT DEFERRABLE
) WITH (oids = false);

Best regards

Alexandre
Back to Top
Wagner R. Landgraf View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 2365
Post Options Post Options   Quote Wagner R. Landgraf Quote  Post ReplyReply Direct Link To This Post Posted: 03 Dec 2018 at 7:00pm
Fixed in Data Modeler 3.2.6.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down