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 3E00A678.5070605@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
Hello again

Gary Stainburn wrote:

> Hi folks,
>
> how do I define a referene from 2 columns in 1 table to 2 columns in 
> another.
>
> I have:
>
> 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
> );
>
>
>
>
> I would now like to define the following table so that inserts can 
> only happen
> if jdid matches rdid and jrank matches rrank.
>
> create table jobtypes (
> jid         int4 default nextval('jobs_jid_seq'::text) unique not null,
> jdid        character references ranks(rdid),    -- This joint reference
> jrank        int4 not null references ranks(rrank),    -- needs sorting
> jdesc        character varying(40)    -- job description

!!!here!!! ,CONSTRAINT c2 FOREIGN KEY(jid,jdid) REFERENCES ranks (rid,rdid)

> );

that's all
Tomasz Myrta



pgsql-sql by date:

Previous
From: Gary Stainburn
Date:
Subject: references table(multiple columns go here)
Next
From: Tim Perdue
Date:
Subject: Re: pl/pgsql question