pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jerome Alet <alet@librelogiciel.com>
To: Achilleus Mantzios <achill@matrix.gatewaynet.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: not sure about constraints
Date: Fri, 2 Sep 2005 16:26:57 +0200
Message-ID: <20050902142657.GE10284@mail.librelogiciel.com> (raw)
In-Reply-To: <Pine.LNX.4.44.0509021626160.8396-100000@matrix.gatewaynet.com>
References: <20050902132356.GD10284@mail.librelogiciel.com>
	<Pine.LNX.4.44.0509021626160.8396-100000@matrix.gatewaynet.com>

On Fri, Sep 02, 2005 at 04:43:15PM +0300, Achilleus Mantzios wrote:
> O Jerome Alet ?????? ???? Sep 2, 2005 :
> 
> > I've got 4 tables :
> > 
> > CREATE TABLE tableA (id SERIAL PRIMARY KEY NOT NULL,
> >                      blahA TEXT);
> >                      
> > CREATE TABLE tableB (id SERIAL PRIMARY KEY NOT NULL,
> >                      blahB TEXT);
> >                      
> > CREATE TABLE tableC (id SERIAL PRIMARY KEY NOT NULL,                     
> >                      ida INT4 REFERENCES tableA(id),
> >                      idb INT4 REFERENCES tableB(id),
> >                      blahC TEXT);
> >                      
> > CREATE TABLE tableD 
> >     (id SERIAL PRIMARY KEY NOT NULL,                     
> >      ida INT4,
> >      idb INT4,
> >      blahC TEXT,
> >      CONSTRAINT checkAB FOREIGN KEY (ida, idb) REFERENCES tableC(ida, idb));
> 
> The above statement is in error.
> In order to create FK to another table (tableC), you must do this
> on tableC's PK (id) or some UNIQUE key in general.

sorry, while adapting the code for the purpose of posting here,
I've forgotten that I've this line in my real script :

  CREATE UNIQUE INDEX tableCindex ON tableC (ida, idb);
  
So I think tableD should be OK (BTW I don't have any error)

Thanks for your help

bye

Jerome Alet



view thread (3+ messages)

Message-ID: <20050902142657.GE10284@mail.librelogiciel.com>
Permalink:  ../20050902142657.GE10284@mail.librelogiciel.com/
Also on:    postgresql.org/message-id/20050902142657.GE10284@mail.librelogiciel.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: alet@librelogiciel.com, achill@matrix.gatewaynet.com
  Subject: Re: not sure about constraints
  In-Reply-To: <20050902142657.GE10284@mail.librelogiciel.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox