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? ---------------------------(end of broadcast)--------------------------- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq