Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E409F475DAD for ; Thu, 19 Dec 2002 04:55:58 -0500 (EST) Received: from serwer.skawsoft.com.pl (serwer.skawsoft.com.pl [213.25.37.66]) by postgresql.org (Postfix) with ESMTP id 44DE54758E1 for ; Thu, 19 Dec 2002 04:55:58 -0500 (EST) Received: from klaster.net (pt53.krakow.cvx.ppp.tpnet.pl [217.99.216.53]) by serwer.skawsoft.com.pl (Postfix) with ESMTP id B4F042B851; Thu, 19 Dec 2002 10:39:26 +0100 (CET) Message-ID: <3E019829.204@klaster.net> Date: Thu, 19 Dec 2002 10:58:01 +0100 From: Tomasz Myrta User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; en-US; rv:1.2b) Gecko/20021016 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Gary Stainburn Cc: pgsql-sql@postgresql.org Subject: Re: references table(multiple columns go here) References: <200212181625.11316.gary.stainburn@ringways.co.uk> <200212181718.42870.gary.stainburn@ringways.co.uk> <8026.1040233829@sss.pgh.pa.us> <200212190928.19736.gary.stainburn@ringways.co.uk> In-Reply-To: <200212181625.11316.gary.stainburn@ringways.co.uk> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200212/232 X-Sequence-Number: 10820 Gary Stainburn wrote: > That did the trick. However, I now have another problem with the > constraint > complaining about there not being an index to refer to. However, > there is. > Output below: > > create table ranks ( > rid int4 default nextval('ranks_rid_seq'::text) unique not null, > rdid character references depts(did), -- department > rrank int4 not null, -- departmental rank > rdesc character varying(40) -- Rank Description ,CONSTRAINT ranks_pkey PRIMARY KEY (rid,rrank) or ,CONSTRAINT ranks_unq UNIQUE (rid,rrank) > > ); Create primary key on two fields in table ranks, or at least create unique constraint on them. If rid is unique, why do you use two fields as foreign key? "rid" is enough. You can get rid of "rrank" in table jobtypes. And one more question - why you don't use the same names in all tables? "did" instead of "did" "rdid" "jdid" ? It's much easier to create joins when using the same names. Tomasz Myrta