Re: FK v.s unique indexes

From: Tim Cross <theophilusx(at)gmail(dot)com>
To: Rafal Pietrak <rafal(at)ztk-rp(dot)eu>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: FK v.s unique indexes
Date: 2018-07-03 22:13:28
Message-ID: 87va9wvugn.fsf@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Rafal Pietrak <rafal(at)ztk-rp(dot)eu> writes:

>
> In particular, contrary to what the ERROR says, the target table *does
> have* a "unique constraint matching given keys", admittedly only
> partial. Yet, why should that matter at all? A unique index, partial or
> not, always yield a single row, and that's all what matters for FK. Right?
>
Is that correct? I would have thought that if you have a multi-key
unique index and you only provide values for some of the keys in the
index, you would have no guarantee of a single row being returned. If
this was true, then the additional keys are superfluous.

Have you tried doing the same thing where the fk keys and remote unique
index keys are equal in number?

--
Tim Cross

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2018-07-03 22:55:37 Re: FK v.s unique indexes
Previous Message Tom Lane 2018-07-03 21:00:17 Re: When exactly is a TIMESTAMPTZ converted to the sessions time zone?