From: | Martijn van Oosterhout <kleptog(at)svana(dot)org> |
---|---|
To: | tom dyson <tom(at)torchbox(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: conditional constraints |
Date: | 2003-04-11 12:03:06 |
Message-ID: | 20030411120304.GB20270@svana.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Fri, Apr 11, 2003 at 12:38:21PM +0100, tom dyson wrote:
> (on behalf of my colleague, Neal Todd)
>
> This question is about whether it's possible to have conditionality on a
> constraint, or rather (presuming it's not possible), how it can be emulated
> perhaps with a trigger.
>
> The scenario is this (but is fairly general anyway)...
>
> Table "P" storing projects with a project id primary key.
> and
> Table "D" storing diary entries relating to projects with foreign key
> constraint referencing project ids in table "P".
>
> Fine so far, we have referential integrity on the project ids in table "D".
>
> However, we need to add diary entries that are for a generic "non-project"
> category. Without the constraint we could just have a null or dummy (e.g. 0)
> entry in D's project id foreign key. But with the constraint the referential
> integrity is broken.
If you put a NULL, it should do what you want.
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> "the West won the world not by the superiority of its ideas or values or
> religion but rather by its superiority in applying organized violence.
> Westerners often forget this fact, non-Westerners never do."
> - Samuel P. Huntington
From | Date | Subject | |
---|---|---|---|
Next Message | Jan Wieck | 2003-04-11 13:15:15 | Re: conditional constraints |
Previous Message | Jan Wieck | 2003-04-11 11:48:06 | Re: Batch replication ordering (was Re: [GENERAL] 32/64-bit |