Re: Foreign Key Unique Constraint can be dropped

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Vlado Moravec <vm(dot)devs(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Foreign Key Unique Constraint can be dropped
Date: 2009-06-08 13:50:53
Message-ID: 12053.1244469053@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Vlado Moravec <vm(dot)devs(at)gmail(dot)com> writes:
> from postgres docs: "foreign key must reference columns that either are a
> primary key or form a unique constraint". It does not allow creating foreign
> key constraint on non-unique column - an error is raised.
> After playing with a new database I discovered that such a unique constraint
> can be droped after the foreign key constraint has been established. No
> warning, no error.

Not in any remotely modern version of Postgres. Maybe you had more than
one unique index, and it chose the other one as the FK's dependency?
There's nothing prohibiting the creation of redundant indexes ...

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message BlackMage 2009-06-08 15:04:37 Entering time into postgresql
Previous Message Preeti Khurana 2009-06-08 13:38:16 Postgres's Performance degrades after heavy db operation