FOREIGN KEY Reference on multiple columns

From: Weiss, Jörg <J(dot)Weiss(at)dvz-mv(dot)de>
To: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: FOREIGN KEY Reference on multiple columns
Date: 2014-09-23 09:54:15
Message-ID: 4B4E89127868BD458A795430BCF4FD1328C51A6F@DVZSN-RA0325.bk.dvz-mv.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi!

Is it possible to create a "FOREIGN KEY CONSTRAINT" with references to multiple columns of the reference table?

For example:
Table parm:
CREATE TABLE parm
(
complex varchar(20) NOT NULL,
para varchar(50) NOT NULL,
sort int4 NOT NULL DEFAULT 10,
value varchar(50) NULL,
CONSTRAINT parm_pkey PRIMARY KEY (complex, para, sort)
)

Table user
CREATE TABLE user
(
name varchar(20) NOT NULL,
type integer NULL
)

Now I want to create FOREIGN KEY on user.type with references on parm.value and param.para WHERE param.para = 'user_type'
Something like this:
ALTER TABLE user ADD CONSTRAINT user_type_fkey FOREIGN KEY (type) REFERENCES parm (value,para) WHERE parm.para = 'user_type';

Regards ...

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Luca Vernini 2014-09-23 09:59:22 Re: FOREIGN KEY Reference on multiple columns
Previous Message Dev Kumkar 2014-09-19 14:09:05 Re: pg_multixact issues