Why does Postgres allow duplicate (FK) constraints

From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Why does Postgres allow duplicate (FK) constraints
Date: 2013-03-26 15:55:40
Message-ID: kisgbp$f45$1@ger.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I was a bit surprised that the following DDL will work:

create table parent (id integer not null primary key);
create table child (id integer not null primary key, pid integer not null);

alter table child
add constraint fk_child_parent
foreign key (pid) references parent(id);

alter table child
add foreign key (pid) references parent(id);

It essentially creates the same foreign key constraint twice.

While I agree that this SQL should not have been written like this in the first place, I wonder why Postgres doesn't actively prevent this (like e.g. Oracle).

Is there a technical reason, or is it simply a matter of "no one cared enough to change this"?

Regards
Thomas

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2013-03-26 16:03:36 Re: Why does Postgres allow duplicate (FK) constraints
Previous Message Clemens Eisserer 2013-03-26 14:27:26 Re: Do "after update" trigger block the current transaction?