Re: unique constraint on 2 columns - Mailing list pgsql-general

From Vladimir Zelinski
Subject Re: unique constraint on 2 columns
Date
Msg-id 606523.60764.qm@web52708.mail.re2.yahoo.com
Whole thread Raw
In response to Re: unique constraint on 2 columns  (Jorge Godoy <jgodoy@gmail.com>)
Responses Re: unique constraint on 2 columns  (Jonathan Vanasco <postgres@2xlp.com>)
List pgsql-general
This looks like more table design problem than
database limitation.
The one column should accommodate values from both
columns with unique index built on this column. Your
requirements tell me that these values are the same
nature and should be placed in the same column. To
distinguish between them use another column to put an
attribute.


--- Jorge Godoy <jgodoy@gmail.com> wrote:

> Jonathan Vanasco <postgres@2xlp.com> writes:
>
> > I need a certain unique constraint in pg that i
> can't figure out.
> >
> > Given:
> >
> >     create table test_a (
> >         id serial ,
> >         name_1 varchar(32) ,
> >         name_2 varchar(32)
> >     );
> >
> > I need name_1 and name_2 to both be unique so
> that:
> >     name_1 never appears in name_1 or name_2
> >     name_2 never appears in name_2 or name_1
> >
> >
> > a standard 2 column unique index / constraint will
> not accomplish this.
>
> But a trigger will...
>
> --
> Jorge Godoy      <jgodoy@gmail.com>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster
>


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: cant get pg_dump/pg_restore to behave
Next
From: Tom Lane
Date:
Subject: Re: large table problem