pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Paul Lambert <paul.lambert@autoledgers.com.au>
To: pgsql-sql <pgsql-sql@postgresql.org>
Subject: Quick question re foreign keys.
Date: Wed, 24 Oct 2007 10:03:01 +0800
Message-ID: <471EA7D5.9040403@autoledgers.com.au> (raw)

I have a table where one column references by foreign key a column from 
another table. However, the column in this first table does not always 
contain data which results in a not-null constraint violation when I 
attempt an insert.

My question therefore is, is it possible to create a foreign key that is 
conditional, i.e. only enforce the foreign key where the value in that 
table is not null.

-- 
Paul Lambert
Database Administrator
AutoLedgers




view thread (9+ messages)  latest in thread

Message-ID: <471EA7D5.9040403@autoledgers.com.au>
Permalink:  ../471EA7D5.9040403@autoledgers.com.au/
Also on:    postgresql.org/message-id/471EA7D5.9040403@autoledgers.com.au

 · 

reply

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: paul.lambert@autoledgers.com.au
  Subject: Re: Quick question re foreign keys.
  In-Reply-To: <471EA7D5.9040403@autoledgers.com.au>

* 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