Re: multiple UNIQUE indices for FK

From: Rafal Pietrak <rafal(at)ztk-rp(dot)eu>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: multiple UNIQUE indices for FK
Date: 2016-03-01 22:39:39
Message-ID: 56D61A2B.80102@ztk-rp.eu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

W dniu 01.03.2016 o 20:02, Igor Neyman pisze:
[--------------------]
>
>
> It just occured to me: how do I make sure (e.g. force within a database) with the above structure, that a message can have *only one* sender?
> but, allow for multiple recepients?
>
> -R
>
> ____________________________________________________________________________________
>
> If I'm not too late, unique partial index:
>
> CREATE UNIQUE INDEX unique_message_sender (message_id, person_id) WHERE relationship_type = sender;
>

Of cource.

Apparently I'm so twisted after the numerous rewrites of my schema for
this project, that I forget the obvious.

Thenx,

-R

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message drum.lucas@gmail.com 2016-03-01 22:48:43 Schema Size
Previous Message Alvaro Herrera 2016-03-01 22:14:09 Re: commit time in logical decoding