agora inbox for pgsql-sql@postgresql.org
help / color / mirror / Atom feedFrom: Adrian Klaver <adrian.klaver@aklaver.com>
To: "Weiss, Jörg" <J.Weiss@dvz-mv.de>
To: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: Re: FOREIGN KEY Reference on multiple columns
Date: Tue, 23 Sep 2014 06:15:10 -0700
Message-ID: <5421725E.3030007@aklaver.com> (raw)
In-Reply-To: <4B4E89127868BD458A795430BCF4FD1328C51ACB@DVZSN-RA0325.bk.dvz-mv.net>
References: <4B4E89127868BD458A795430BCF4FD1328C51A6F@DVZSN-RA0325.bk.dvz-mv.net>
<CAHZ=uVAE3cobpckU+oyYWwF+ENr0UmYAhgu+kRrwmOc+t=g1nw@mail.gmail.com>
<4B4E89127868BD458A795430BCF4FD1328C51ACB@DVZSN-RA0325.bk.dvz-mv.net>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>
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 <J.Weiss@dvz-mv.de>:
>>> 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
view thread (10+ messages) latest in thread
Message-ID: <5421725E.3030007@aklaver.com>
Permalink: ../5421725E.3030007@aklaver.com/
Also on: postgresql.org/message-id/5421725E.3030007@aklaver.com
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: adrian.klaver@aklaver.com, J.Weiss@dvz-mv.de
Subject: Re: FOREIGN KEY Reference on multiple columns
In-Reply-To: <5421725E.3030007@aklaver.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox