Re: UNIQUE not unique with inheritance (workaround?)

Lists: pgsql-hackers
From: Samuel Sieb <samuel(at)sieb(dot)net>
To: PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org>
Subject: UNIQUE not unique with inheritance (workaround?)
Date: 2003-02-08 19:34:05
Message-ID: 3E455BAD.3040005@sieb.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Is there any workaround for this problem? I'm getting involved in a
project where inheritance is an incredibly useful feature, but the
non-unique issue could be a serious stumbling block. Is there any way
to work around it with a trigger or something?


From: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
To: Samuel Sieb <samuel(at)sieb(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Re: UNIQUE not unique with inheritance (workaround?)
Date: 2003-02-08 22:12:01
Message-ID: 1044742320.25462.58.camel@linda.lfix.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sat, 2003-02-08 at 19:34, Samuel Sieb wrote:
> Is there any workaround for this problem? I'm getting involved in a
> project where inheritance is an incredibly useful feature, but the
> non-unique issue could be a serious stumbling block. Is there any way
> to work around it with a trigger or something?

Give each table in the hierarchy a foreign key reference to another
table which holds a unique list of the primary keys and a column that
says which table they are in. Use triggers to update this other table
and to prevent duplications in the hierarchy.

.
--
Oliver Elphick Oliver(dot)Elphick(at)lfix(dot)co(dot)uk
Isle of Wight, UK http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C
========================================
"But the LORD is in his holy temple; let all the earth
keep silence before him." Habakkuk 2:20


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
Cc: Samuel Sieb <samuel(at)sieb(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: UNIQUE not unique with inheritance (workaround?)
Date: 2003-02-12 18:33:35
Message-ID: 200302121833.h1CIXZx24364@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


Or create a sequence, and make each table in the inheritance hierarchy
use the same sequence as it's default value.

---------------------------------------------------------------------------

Oliver Elphick wrote:
> On Sat, 2003-02-08 at 19:34, Samuel Sieb wrote:
> > Is there any workaround for this problem? I'm getting involved in a
> > project where inheritance is an incredibly useful feature, but the
> > non-unique issue could be a serious stumbling block. Is there any way
> > to work around it with a trigger or something?
>
> Give each table in the hierarchy a foreign key reference to another
> table which holds a unique list of the primary keys and a column that
> says which table they are in. Use triggers to update this other table
> and to prevent duplications in the hierarchy.
>
> .
> --
> Oliver Elphick Oliver(dot)Elphick(at)lfix(dot)co(dot)uk
> Isle of Wight, UK http://www.lfix.co.uk/oliver
> GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C
> ========================================
> "But the LORD is in his holy temple; let all the earth
> keep silence before him." Habakkuk 2:20
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073