From: | Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com> |
---|---|
To: | George Young <gry(at)ll(dot)mit(dot)edu> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: trigger to enforce FK with nulls? |
Date: | 2006-04-13 01:26:18 |
Message-ID: | 20060412182501.X57788@megazone.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Wed, 12 Apr 2006, George Young wrote:
> [PostgreSQL 8.1.3 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 4.0.1]
>
> I'm starting to use lots of foreign key constraints to keep my
> data clean. In one case, however, I need to allow null values
> for the key. E.g.:
>
> create table opset_steps(opset text, step text, step_num int);
> create table steps(run text, step text, opset text, user text, step_num int);
>
> The constraint on steps should be:
> steps.(opset,step) must be found in opset_steps.(opset,step) UNLESS steps.opset is null.
The default foreign key case should not error if either steps.opset or
steps.step is null. If you're seeing something else, can you give a
complete test case?
From | Date | Subject | |
---|---|---|---|
Next Message | Gregory S. Williamson | 2006-04-13 02:43:00 | Truncate and Foreign Key References question |
Previous Message | Alvaro Herrera | 2006-04-13 01:22:22 | Re: trigger to enforce FK with nulls? |