pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tomasz Myrta <jasiek@klaster.net>
To: Gary Stainburn <gary.stainburn@ringways.co.uk>
Cc: pgsql-sql@postgresql.org
Subject: Re: references table(multiple columns go here)
Date: Thu, 19 Dec 2002 10:58:01 +0100
Message-ID: <3E019829.204@klaster.net> (raw)
In-Reply-To: <200212181625.11316.gary.stainburn@ringways.co.uk>
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>

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





view thread (13+ messages)  latest in thread

Message-ID: <3E019829.204@klaster.net>
Permalink:  ../3E019829.204@klaster.net/
Also on:    postgresql.org/message-id/3E019829.204@klaster.net

 · 

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: jasiek@klaster.net, gary.stainburn@ringways.co.uk
  Subject: Re: references table(multiple columns go here)
  In-Reply-To: <3E019829.204@klaster.net>

* 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