Re: multiple UNIQUE indices for FK - Mailing list pgsql-general

From David G. Johnston
Subject Re: multiple UNIQUE indices for FK
Date
Msg-id CAKFQuwZSRiDJcAkNT73oE0z4bqLBPpcYszbAm_vWvZEY16DYCg@mail.gmail.com
Whole thread Raw
In response to Re: multiple UNIQUE indices for FK  (Rafal Pietrak <rafal@ztk-rp.eu>)
List pgsql-general
Sorry for the delay - used to getting replied-to-all on messages I send but you didn't and I didn't notice the response until now.

On Mon, Feb 29, 2016 at 4:03 AM, Rafal Pietrak <rafal@ztk-rp.eu> wrote:
>
> Partitioning and partial indexes both have considerable limitations that
> you might need to work around.  That said normalization exists for a
> reason and having multiple "person" columns in a table is a form of
> duplication that if left presents just the problems you are seeing.
>
> I suspect your SSN should fit onto the message-person table.
>
> The following doesn't make sense - if the SSN is sender unique then
> there is no expectation that a receiver would not receive two messages
> with the same SSN from different senders.

I don't get it.

Of cource it's possible to receive two messages with the same SSN.

By "sender unique" I mean, that every sender has full control of
whatever he/she wishes to use for SSN, provided that he/she does not
assign duplicates. It also means, that there is no relation between SSN
assigned by different senders and collisions *should* be expected unless
UNIQUE covers both THEM/SENDR and SSN.

Thus:
> ALTER ... msgs_to_me ADD CONSTRINT them_uniq UNIQUE (THEM,SSN);


​Yeah, mental lapse on my part.​

​​David J.

pgsql-general by date:

Previous
From: Weiping Qu
Date:
Subject: Re: commit time in logical decoding
Next
From: Alvaro Herrera
Date:
Subject: Re: commit time in logical decoding