Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XWPwH-0004Qz-8Y for pgsql-sql@arkaria.postgresql.org; Tue, 23 Sep 2014 13:15:29 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XWPwG-0001VS-7z for pgsql-sql@arkaria.postgresql.org; Tue, 23 Sep 2014 13:15:28 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XWPw9-0001I7-5V for pgsql-sql@postgresql.org; Tue, 23 Sep 2014 13:15:21 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by makus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XWPw1-0001Rq-9A for pgsql-sql@postgresql.org; Tue, 23 Sep 2014 13:15:19 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by gateway2.nyi.internal (Postfix) with ESMTP id 7C24D20B23 for ; Tue, 23 Sep 2014 09:15:11 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute5.internal (MEProxy); Tue, 23 Sep 2014 09:15:11 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=aklaver.com; h= message-id:date:from:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; s=mesmtp; bh=c4HkMrfx21tKt7dI78H3V4A0AmE=; b=k5IKOOEmAKiQcf6meOgPFA5kn3F7 SaaQ8HAtvI61JvztlYIjMwdPzJMqYGXGC9YdMkDMD9RSLzTcuT0YtdC8VNgUT2Bn HX1Y4uZeXcBZ4q5Bs+YIjwFi7ZmYecVAJLP8osFepXTQ4SVXmUafB2J9cZptn0Zd GH4X1dAmPHJfM5w= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=message-id:date:from:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; s=smtpout; bh=c4HkMrfx21tKt7dI78H3V4 A0AmE=; b=gcTlR/oGyv7ooHbEIS27RD8v7goqJvOJFJ0sjoNu/0MMRFSJTcTOR3 TDa2VISxUir48gL0WTlE+9dW3qsQKcE2SQwtA7ndWgfwwIB0uSZgyn9b8k1+HOHN QRe9UbEDRM5TI4ZGi27iX4+ciC/ITNM54KAidWclUKvhp/h+3pX+g= X-Sasl-enc: J1htZfuGg8Eo0cn84Wv0DGCx6++DvJCzSOePGqepyqhq 1411478111 Received: from [192.168.1.5] (unknown [174.21.177.1]) by mail.messagingengine.com (Postfix) with ESMTPA id 0EC38C00915; Tue, 23 Sep 2014 09:15:10 -0400 (EDT) Message-ID: <5421725E.3030007@aklaver.com> Date: Tue, 23 Sep 2014 06:15:10 -0700 From: Adrian Klaver User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: =?UTF-8?B?IldlaXNzLCBKw7ZyZyI=?= , "pgsql-sql@postgresql.org" Subject: Re: FOREIGN KEY Reference on multiple columns References: <4B4E89127868BD458A795430BCF4FD1328C51A6F@DVZSN-RA0325.bk.dvz-mv.net> <4B4E89127868BD458A795430BCF4FD1328C51ACB@DVZSN-RA0325.bk.dvz-mv.net> In-Reply-To: <4B4E89127868BD458A795430BCF4FD1328C51ACB@DVZSN-RA0325.bk.dvz-mv.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Pg-Spam-Score: -2.7 (--) 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 On 09/23/2014 04:38 AM, Weiss, Jörg wrote: >> -----Ursprüngliche Nachricht----- >> Von: Luca Vernini [mailto:lucazeo@gmail.com] >> Gesendet: Dienstag, 23. September 2014 11:59 >> An: Weiss, Jörg >> Cc: pgsql-sql@postgresql.org >> Betreff: Re: [SQL] FOREIGN KEY Reference on multiple columns >> >> 2014-09-23 11:54 GMT+02:00 Weiss, Jörg : >>> Hi! >> Hi. >> >>> Is it possible to create a “FOREIGN KEY CONSTRAINT” with references to >>> multiple columns of the reference table? >> >> Yes, it is. >> >> see here: >> http://www.postgresql.org/docs/9.3/static/ddl-constraints.html >> Section 5.3.5 there are some examples. One of them has multiple >> columns, just like your case. >> >>> Regards … >> >> Regards. > > Thank you! > > Do you mean this example? > CREATE TABLE t1 ( > a integer PRIMARY KEY, > b integer, > c integer, > FOREIGN KEY (b, c) REFERENCES other_table (c1, c2) > ); > This is not, what I want. > > In my case it should be something like this: > CREATE TABLE t1 ( > a integer PRIMARY KEY, > b integer, > c integer, > FOREIGN KEY (b) REFERENCES other_table (c1, c2='c2Value') > ); > This example does not work. But I think you can see, what I mean. Foreign keys do not support the when clause. In your original example there is also the problem that value is not part of a unique index or the primary key. > > > -- Adrian Klaver adrian.klaver@aklaver.com -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql