From: Jerome Alet <alet@librelogiciel.com>
To: pgsql-sql@postgresql.org
Subject: not sure about constraints
Date: Fri, 2 Sep 2005 15:23:56 +0200
Message-ID: <20050902132356.GD10284@mail.librelogiciel.com> (raw)
Hello,
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));
Is the definition of tableD sufficient, or should I do it this way
instead :
CREATE TABLE tableD
(id SERIAL PRIMARY KEY NOT NULL,
ida INT4 REFERENCES tableA(id),
idb INT4 REFERENCES tableB(id),
blahD TEXT,
CONSTRAINT checkAB FOREIGN KEY (ida, idb) REFERENCES tableC(ida, idb));
which looks superfluous to me.
???
Thanks in advance
Jerome Alet
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
Subject: Re: not sure about constraints
In-Reply-To: <20050902132356.GD10284@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