From: | Vladimir Zelinski <zelvlad(at)yahoo(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: unique constraint on 2 columns |
Date: | 2007-04-20 21:43:38 |
Message-ID: | 606523.60764.qm@web52708.mail.re2.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(at)gmail(dot)com> wrote:
> Jonathan Vanasco <postgres(at)2xlp(dot)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(at)gmail(dot)com>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster
>
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2007-04-20 21:52:03 | Re: large table problem |
Previous Message | Tom Lane | 2007-04-20 21:31:01 | Re: cant get pg_dump/pg_restore to behave |