Re: constrain with MATCH full and NULL values in referenced table

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: stan <stanb(at)panix(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: constrain with MATCH full and NULL values in referenced table
Date: 2019-08-12 15:27:28
Message-ID: 5361.1565623648@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

stan <stanb(at)panix(dot)com> writes:
> I am creating a table that has 2 values in it which are keys pointing to 2
> other tables. I need for the UNIQUE combination of these 2 keys to exist in
> a fourth table. It has been recommended to use a foreign key constraint with
> the MATCH FULL parameter.
> Here is my question, does this deal with NULLS in the 4th table? I am
> concerned that this constraint might fail to reject an entry if one, or both
> of the 2 key values being inserted in the table are NULLS,.

If you don't want nulls there, maybe add NOT NULL constraints to those
columns?

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2019-08-12 16:05:57 Re: constrain with MATCH full and NULL values in referenced table
Previous Message Adrian Klaver 2019-08-12 15:17:33 Re: constrain with MATCH full and NULL values in referenced table