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: Wed, 18 Dec 2002 17:46:48 +0100
Message-ID: <3E00A678.5070605@klaster.net> (raw)
In-Reply-To: <200212181625.11316.gary.stainburn@ringways.co.uk>
References: <200212181625.11316.gary.stainburn@ringways.co.uk>

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




view thread (13+ messages)  latest in thread

Message-ID: <3E00A678.5070605@klaster.net>
Permalink:  ../3E00A678.5070605@klaster.net/
Also on:    postgresql.org/message-id/3E00A678.5070605@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: <3E00A678.5070605@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