From: | Andreas <maps(dot)on(at)gmx(dot)net> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Cc: | Kretschmer Andreas <akretschmer(at)spamfence(dot)net>, M(dot)Mamin(at)intershop(dot)de |
Subject: | Re: Prevent double entries ... no simple unique index |
Date: | 2012-07-12 08:44:32 |
Message-ID: | 4FFE8E70.3060109@gmx.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Am 12.07.2012 07:14, schrieb Andreas Kretschmer:
> Marc Mamin <M(dot)Mamin(at)intershop(dot)de> wrote:
>
>> A partial index would do the same, but requires less space:
>>
>> create unique index on log(state) WHERE state IN (0,1);
>
OK, nice :)
What if I have those states in a 3rd table?
So I can see a state-history of when a state got set by whom.
objects ( id serial PK, ... )
events ( id serial PK, object_id integer FK on objects.id, ... )
event_states ( id serial PK, event_id integer FK on events.id, state
integer )
There still should only be one event per object that has state 0 or 1.
Though here I don't have the object-id within the event_states-table.
Is it still possible to have a unique index that needs to span over a
join of events and event_states?
From | Date | Subject | |
---|---|---|---|
Next Message | David Johnston | 2012-07-12 13:40:12 | Re: Prevent double entries ... no simple unique index |
Previous Message | Andreas Kretschmer | 2012-07-12 05:14:45 | Re: Prevent double entries ... no simple unique index |