Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hxCEV-0006UE-5Q for pgsql-general@arkaria.postgresql.org; Mon, 12 Aug 2019 15:27:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hxCEU-0003xa-0C for pgsql-general@arkaria.postgresql.org; Mon, 12 Aug 2019 15:27:38 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hxCET-0003xR-K0 for pgsql-general@lists.postgresql.org; Mon, 12 Aug 2019 15:27:37 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1hxCEM-0002zO-MU for pgsql-general@postgresql.org; Mon, 12 Aug 2019 15:27:35 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x7CFRSk0005362; Mon, 12 Aug 2019 11:27:28 -0400 From: Tom Lane To: stan cc: pgsql-general@postgresql.org Subject: Re: constrain with MATCH full and NULL values in referenced table In-reply-to: <20190812151115.GA8819@panix.com> References: <20190812151115.GA8819@panix.com> Comments: In-reply-to stan message dated "Mon, 12 Aug 2019 11:11:15 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <5360.1565623648.1@sss.pgh.pa.us> Date: Mon, 12 Aug 2019 11:27:28 -0400 Message-ID: <5361.1565623648@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk stan 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