Re: Surrogate Keys: an Implementation Issue

From: J M Davitt <jdavitt_at_aeneas.net>
Date: Fri, 28 Jul 2006 09:39:44 GMT
Message-ID: <AXkyg.58334$Eh1.49774_at_tornado.ohiordc.rr.com>


JOG wrote:

> J M Davitt wrote:
> 

>>[big snip]
>>
>>
>>>What does that have to do with the
>>>fact that Bob just updated the wrong row?
>>
>>The wrong row? What was wrong about it? The database was
>>told, for example, "Make Suzie's record look like this."
>>
>>The confusion arising because "Suzie is George and William
>>is Suzie but Bob thought George was still Suzie" isn't
>>going away just because you slap another value on all your
>>records; you're just moving the confusion around.
> 
> 
> 
> There is miscommunication in this thread. Brian is coming from an
> assumption that primary keys are mutable, and everyone else from the RM
> specification that they should be immutable. The primary key identifies
> a tuple, and if something's identity changes... well, conceptually, it
> is a completely different thing. Hence in the example you supply Brian,
> the RM is responding perfectly and as we would want it to.

A couple things: I'm not presuming that primary key values are immutable. I'm not sure what you mean when you say "from the RM specification that they should be immutable."

I don't think I agree that a "thing" changes because one of its attributes changes. Yes, the tuple representing it does but the thing is the same. For instance, the change in the database may occur because the value for some attribute was incorrectly recorded; that doesn't mean there was a different thing. Or instance of an entity. Whatever.

> It is the database designer and his choice of primary key that is
> causing the problems. A person's name is an absolutely dire choice as a
> key given they are _not unique_ and _subject to change_. That's exactly
> why you guys have SSN's and I have an UK National Insurance ID. But
> then to me an SSN isn't a surrogate anyhow, it's a unique attribute.

I agree with everything in the above paragraph except that SSN is a unique attribute. Yes, the lack of readily available and reliable identifiers is troublesome - but it doesn't mean that any made-up identifier is going to solve the problems Brian was describing.

>>Surrogates aren't going to solve the problems stemming
>>from the fact that Bob is working on a stale and partly
>>wrong representation of the data.
>>
>>
>>
>>>How could you prevent that in
>>>application code, or in the middle-tier? You can't, unless you either (1)
>>>lock the row until Bob gets back from Tahiti, or (2) use a surrogate to
>>>guarantee that the row that's about to be updated is the same as the one
>>>that was read out.
>>
>>Your list is too short; there are more alternatives. We
>>don't have to wait for Bob and a surrogate isn't going to
>>solve the problem without creating another problem.
>>
>>
>>>>You are a vociferous ignoramus. It suffices to observe that fact.
>>>>
>>>>[remaining nonsense snipped without further effort]
>>>
>>>
>>>
> Received on Fri Jul 28 2006 - 11:39:44 CEST

Original text of this message