Re: references table(multiple columns go here) - Mailing list pgsql-sql

From Tomasz Myrta
Subject Re: references table(multiple columns go here)
Date
Msg-id 3E019829.204@klaster.net
Whole thread Raw
In response to references table(multiple columns go here)  (Gary Stainburn <gary.stainburn@ringways.co.uk>)
Responses Re: references table(multiple columns go here)  (Gary Stainburn <gary.stainburn@ringways.co.uk>)
List pgsql-sql
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




pgsql-sql by date:

Previous
From: Gary Stainburn
Date:
Subject: Re: references table(multiple columns go here)
Next
From: Gary Stainburn
Date:
Subject: Re: references table(multiple columns go here)