X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C451F3A5E1B for ; Thu, 27 Jan 2005 11:44:40 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 46910-03 for ; Thu, 27 Jan 2005 11:44:28 +0000 (GMT) Received: from ar-sd.net (unknown [82.77.155.72]) by svr1.postgresql.org (Postfix) with ESMTP id 2E3003A5E7C for ; Thu, 27 Jan 2005 11:44:30 +0000 (GMT) Received: from localhost (localhost [127.0.0.1]) by ar-sd.net (Postfix) with ESMTP id AD8E51EBF1 for ; Thu, 27 Jan 2005 13:39:28 +0200 (EET) Received: from ar-sd.net ([127.0.0.1]) by localhost (linz [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 13422-02 for ; Thu, 27 Jan 2005 13:39:27 +0200 (EET) Received: from forge (unknown [192.168.0.11]) by ar-sd.net (Postfix) with SMTP id B81701EBD7 for ; Thu, 27 Jan 2005 13:39:26 +0200 (EET) Message-ID: <013b01c50465$93854580$0b00a8c0@forge> From: "Andrei Bintintan" To: Subject: Constraint on 2 column possible? Date: Thu, 27 Jan 2005 13:44:32 +0200 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0138_01C50476.54D1E120" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-Virus-Scanned: by amavisd-new at ar-sd.net X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.013 tagged_above=0 required=5 tests=AWL, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200501/281 X-Sequence-Number: 20069 This is a multi-part message in MIME format. ------=_NextPart_000_0138_01C50476.54D1E120 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi,=20 I have a table: CREATE TABLE werke1( id SERIAL, id_hr int4 NOT NULL, id_wk int4 NOT NULL ); CREATE TABLE contact( id SERIAL, type varchar(20), ); Now id_hr and id_wk are all referencing the same table contact(id). In = the contact table I have another column called type.=20 How can I write a constraint that checks that id_hr references = contact(id) and the contact(type=3D't1') and that id_wk references contact(id) and the contact(type=3D't2').=20 More explicit: the id_hr shows to the id from contact, and this line = from contact must have the line type=3D't1'. The same for id_wk just the = type is another. I can write: CREATE TABLE werke1( id SERIAL, id_hr int4 NOT NULL references contact(id), id_wk int4 NOT NULL references contact(id) ); but how do I check also the type column? Best regards, Andy. ------=_NextPart_000_0138_01C50476.54D1E120 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi,
 
I have a table:
CREATE
TABLE = werke1(

id SERIAL,
id_hr int4 = NOT NULL,
id_wk int4 = NOT NULL
);
 
CREATE TABLE contact(
id = SERIAL,
type=20 varchar(20),
);
 
 
Now id_hr and id_wk are all referencing = the same=20 table contact(id). In the contact table I have another column called = type.=20
How can I write a constraint that = checks that id_hr=20 references contact(id) and the contact(type=3D't1')
and that id_wk references contact(id) = and the=20 contact(type=3D't2').
 
More explicit: the id_hr shows to the = id from=20 contact, and this line from contact must have the line type=3D't1'. The = same for=20 id_wk just the type is another.
 
I can write:
CREATE = TABLE werke1(
id=20 SERIAL,
id_hr int4=20 NOT NULL=20 references contact(id),
id_wk int4 NOT NULL references contact(id)
);
but how do I check also the type=20 column?
 
Best regards,
Andy.
------=_NextPart_000_0138_01C50476.54D1E120--