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: | Re: FOREIGN KEY Reference on multiple columns |
Date: | 2014-09-25 05:04:40 |
Message-ID: | 4B4E89127868BD458A795430BCF4FD1328C53C1B@DVZSN-RA0325.bk.dvz-mv.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
> -----Ursprüngliche Nachricht-----
> Von: pgsql-sql-owner(at)postgresql(dot)org [mailto:pgsql-sql-
> owner(at)postgresql(dot)org] Im Auftrag von Tim Landscheidt
> Gesendet: Mittwoch, 24. September 2014 20:03
> An: pgsql-sql(at)postgresql(dot)org
> Betreff: Re: [SQL] FOREIGN KEY Reference on multiple columns
>
> "Weiss, Jörg" <J(dot)Weiss(at)dvz-mv(dot)de> wrote:
>
> > I mean b must equal to c1 in the "other_table" where c2 has a certain value
> (for example c2 ).
>
> > For my first example:
> > 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
> > )
> > In this case "type" of table user must equal to "value" of table "parm" and
> "para" must be "login_user" (for example)
>
> > [...]
>
> You can achieve that by duplicating the para column to the
> table user, adding a foreign key that matches both columns
> to table parm and checks in table user whether para is
> "login_user". That doesn't work for NULLable columns,
> though.
>
> Tim
>
Yes of cause, this seems to be the best way.
Thank You!
From | Date | Subject | |
---|---|---|---|
Next Message | Gerardo Herzig | 2014-09-25 20:02:27 | uuid for each postgres install? |
Previous Message | Tim Landscheidt | 2014-09-24 18:02:34 | Re: FOREIGN KEY Reference on multiple columns |