From: | Igor Neyman <ineyman(at)perceptron(dot)com> |
---|---|
To: | Rafal Pietrak <rafal(at)ztk-rp(dot)eu>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: multiple UNIQUE indices for FK |
Date: | 2016-03-01 19:02:33 |
Message-ID: | A76B25F2823E954C9E45E32FA49D70ECCD677A7F@mail.corp.perceptron.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
W dniu 28.02.2016 o 03:35, David G. Johnston pisze:
> W dniu 23.02.2016 o 09:39, Rafal Pietrak pisze:
> > Can anybody suggest any other way out of this mass?
>
>
> The only thought that sticks while reading your prose is:
>
> message ----> message-person <---- person
>
>
> message-person (message_id, person_id, relationship_type[sender,
> receiver])
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;
Regards,
Igor
From | Date | Subject | |
---|---|---|---|
Next Message | Steven Xu | 2016-03-01 20:54:15 | Custom column ordering |
Previous Message | Pavel Stehule | 2016-03-01 19:01:26 | Re: Does RAISE EXCEPTION rollback previous commands in a stored function? |