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 A25F85282F for ; Sun, 26 Jun 2005 17:20:45 -0300 (ADT) 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 30079-01 for ; Sun, 26 Jun 2005 20:20:41 +0000 (GMT) Received: from mailout02.albacom.net (mailout02.albacom.net [217.220.34.14]) by svr1.postgresql.org (Postfix) with SMTP id 13DE35281A for ; Sun, 26 Jun 2005 17:20:40 -0300 (ADT) Received: (qmail 21132 invoked by uid 507); 26 Jun 2005 20:20:31 -0000 Received: from site.webmaster@email.it by mailout02.albacom.net with qmail-scanner (rbl: ???. spamassassin: ???. Clear:RC:1(217.221.167.198):RBL:0:SA:0(0.0/1000.0):. Processed in 0.332891 secs); 26 Jun 2005 20:20:31 -0000 Received: from unknown (HELO ?127.0.0.1?) (davide@attutta.albaweb.it@217.221.167.198) by mailout02.albacom.net with SMTP; 26 Jun 2005 20:20:30 -0000 Message-ID: <42BF0E0E.9030906@email.it> Date: Sun, 26 Jun 2005 22:20:30 +0200 From: davide User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Re: multiple PK with a non UNIQUE field Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.032 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_POST X-Spam-Level: * X-Archive-Number: 200506/311 X-Sequence-Number: 21912 > if you need a multi column fk don't use the "references" keyword on your create table, instead use the "FOREIGN KEY" > keyword for the table, see the "create table" help. > > so for example (untested) change > > CREATE TABLE appalto ( > cod_op int not null references Opere, > cod_com int not null references Opere, > scadenza date not null, > importo int not null, > PRIMARY KEY (cod_op,cod_com) > ); > > to > CREATE TABLE appalto ( > cod_op int not null, > cod_com int not null, > scadenza date not null, > importo int not null, > PRIMARY KEY (cod_op,cod_com), > FOREIGN KEY (cod_op,cod_com) REFERENCES Opere(cod_op,cod_com) > ); > In this way it works, thanks.