Re: multi column foreign key for implicitly unique columns

From: Jan Wieck <JanWieck(at)Yahoo(dot)com>
To: olly(at)lfix(dot)co(dot)uk
Cc: Josh Berkus <josh(at)agliodbs(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: multi column foreign key for implicitly unique columns
Date: 2004-08-19 21:41:07
Message-ID: 41251E73.6070001@Yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On 8/19/2004 12:52 PM, Oliver Elphick wrote:
> On Thu, 2004-08-19 at 17:21, Josh Berkus wrote:
>> Jan,
>>
>> > Because the value in b.y is redundant. b.x->a.x->a.y is exactly the same
>> > value and he even wants to ensure this with the constraint.
>>
>> And in the absence of that constraint, what ensures that b.y = a.y, exactly?
>
> In the absence of b.y, it would be impossible for it to be anything
> else. Isn't that the point?

Precisely. I meant that the entire column is redundant and obsolete.
Without the column, no need for any constraint.

> It seems to me that he was trying to use the database to show errors in
> his source data, but since his constraint would reject the data, he
> wouldn't be able to enter it; all he could do would be to see the
> error. So he might as well turn it round, normalise the data properly
> and use the database to tell the rest of the system what the data ought
> to be.

I assumed he often queries b, and to avoid joining a all the time he
duplicates values from a into b and then tries to ensure that they stay
in sync with constraints.

Jan

--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck(at)Yahoo(dot)com #

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tony Yang 2004-08-19 22:00:56 help with scheme changes to live system.
Previous Message Oliver Elphick 2004-08-19 16:52:46 Re: multi column foreign key for implicitly unique columns