Re: Advice on merging two primary keys... - Mailing list pgsql-general

From Stephan Szabo
Subject Re: Advice on merging two primary keys...
Date
Msg-id 20050629053336.F48334@megazone.bigpanda.com
Whole thread Raw
In response to Re: Advice on merging two primary keys...  (Richard Huxton <dev@archonet.com>)
List pgsql-general
On Wed, 29 Jun 2005, Richard Huxton wrote:

> Eric D. Nielsen wrote:
> > I've come into a situation where I will often need to merge two  primary
> > keys, with numerous foreign keys hanging off of them.  For  instance:
>
> > While any update of the either primary key will cascade to all  relevant
> > tables, such an update is disallowed for uniqueness reasons.
> >
> > Is there a good SQL-base method to accomplish this type of merging or
> > does this need application logic?
>
> It's irritating, because (afaict) the main use for cascading updates to
> a primary key is for merging. But, without deferred uniqueness checks
> you'll encounter the problem you mention. PG doesn't allow deferred
> uniqueness checks at the moment, so I'm afraid you'll have to explicitly
> update all the dependant tables.

Deferrable unique constraints probably wouldn't actually help because you
cannot refer a foreign key to a deferred unique constraint.  (SQL92
11.8SR3) "The table constraint descriptor describing the <unique
constraint definition> whose <unique column list> identifies the
referenced columns shall indicate that the unique constraint is not
deferrable."

pgsql-general by date:

Previous
From: Enrico Weigelt
Date:
Subject: Re: Foreign key to a view (UNION of two or more tables),
Next
From: Enrico Weigelt
Date:
Subject: faking writable views as tables