Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WMTcp-0002mc-J9 for pgsql-sql@arkaria.postgresql.org; Sun, 09 Mar 2014 02:38:03 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WMTco-0004pX-E9 for pgsql-sql@arkaria.postgresql.org; Sun, 09 Mar 2014 02:38:02 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WMTcm-0004pK-Fh for pgsql-sql@postgresql.org; Sun, 09 Mar 2014 02:38:00 +0000 Received: from sam.nabble.com ([216.139.236.26]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WMTci-0004Ka-UO for pgsql-sql@postgresql.org; Sun, 09 Mar 2014 02:38:00 +0000 Received: from [192.168.236.26] (helo=sam.nabble.com) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1WMTcg-0005Tv-3O for pgsql-sql@postgresql.org; Sat, 08 Mar 2014 18:37:54 -0800 Date: Sat, 8 Mar 2014 18:37:54 -0800 (PST) From: David Johnston To: pgsql-sql@postgresql.org Message-ID: <1394332674081-5795296.post@n5.nabble.com> In-Reply-To: References: Subject: Re: Foreign key to a partial key MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: 1.8 (+) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org > I thought of creating a foreign key constraint this way: > > The constraint would need to make reference to the wbs_name assigned to > the > project, but at the table products, no column contains that info. Add the wbs_name column to the products table. Since a code is invalid without knowing which project it belongs to your table definition is wrong. Then you can create the proper two-column foreign key that references on primary key on the codes table. David J. -- View this message in context: http://postgresql.1045698.n5.nabble.com/Foreign-key-to-a-partial-key-tp5795291p5795296.html Sent from the PostgreSQL - sql mailing list archive at Nabble.com. -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql