FOREIGN KEY Reference on multiple columns - Mailing list pgsql-sql

From Weiss, Jörg
Subject FOREIGN KEY Reference on multiple columns
Date
Msg-id 4B4E89127868BD458A795430BCF4FD1328C51A6F@DVZSN-RA0325.bk.dvz-mv.net
Whole thread
Responses Re: FOREIGN KEY Reference on multiple columns
List 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 …

 

 

pgsql-sql by date:

Previous
From: Kamal Kumar TRR
Date:
Subject: Re: How to compare two tables in PostgreSQL
Next
From: Luca Vernini
Date:
Subject: Re: FOREIGN KEY Reference on multiple columns