From: Stephan Szabo <sszabo@megazone.bigpanda.com>
To: George Young <gry@ll.mit.edu>
Cc: pgsql-sql@postgresql.org
Subject: Re: trigger to enforce FK with nulls?
Date: Wed, 12 Apr 2006 18:26:18 -0700 (PDT)
Message-ID: <20060412182501.X57788@megazone.bigpanda.com> (raw)
In-Reply-To: <20060412211118.05411612.gry@ll.mit.edu>
References: <20060412211118.05411612.gry@ll.mit.edu>
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?
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: sszabo@megazone.bigpanda.com, gry@ll.mit.edu
Subject: Re: trigger to enforce FK with nulls?
In-Reply-To: <20060412182501.X57788@megazone.bigpanda.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox