RoyVidar said:
Isn't it a bit difference between claiming this is unreliable and
should not be used in Jet
and
arguementing that such unreliability may occur *if* there is a lock on
som of the data *if* it at the same time also is a lack of memory or
*if* some other circumstances occur at the same time, this *might*
cancel a rollback.
In your previous post, you asked: "Would you have any more information
supporting cascade updates being so dangerous in Jet?" I gave you the
results of our tests, the conclusion we drew, and the recommendation.
Cascade updates don't fail every time, but when they do fail, there's no
error message, leaving you with your pants down when your boss asks, "Why are
June's sales figures smaller this month than last month for the Chicago,
Minneapolis, and Boise offices when the other offices' sales haven't changed
and total sales haven't changed?" Saying, "It's not my fault. The cascading
update on the foreign key didn't cascade through all the records like it was
supposed to" won't clear up his confusion or give him confidence in the
veracity of your database application.
Well, as I said, it still hasn't catched up, and when searching these
groups, I haven't found any reference to it catching up with anyone
else either. Are you the only one having this problem?
No. It's been discussed twice before. To find those discussions, you'd need
to search the Google Group archive database that Google cleaned up and sped
up for the Google Groups Beta version that we're now using as the production
version. I'd estimate the current database available to the public is
missing about 10% to 15% of the Access Usenet messages from before the
conversion to the *new look.* But it's faster than the old one.
I mean that I'm not going to beat a dead horse. The discussions on natural
keys vs. surrogate keys are available for your reading pleasure. If you want
to participate in those discussions, you don't need to invite me into the
fray too. I use natural keys when it makes sense, and I use surrogate keys
when it makes sense. If have a table of states in the US, I'll use the
natural key, the two-character abbreviation as the primary key, because that
makes sense to me. If I have a table of employees, then I'll use an EMPID
surrogate key and a unique index that doesn't allow NULLs on the natural key,
because that makes sense to me.
Why the dichotomy? Because those state abbreviations are very unlikely to
change during the lifetime of the database, but the last names of many of the
women in the employees table are going to change. When we change a female
employee's last name, we have to change it in one, and *only one,* place in
the entire database, which is the goal of a relational database and my goal
of *do it right the first time* so I don't have to take the time to fix
things repeatedly. The EMPID primary key in the employees table remains
unchanged and the EMPID foreign key in any other table remains unchanged when
we update a woman's last name, so we don't have to wait for a cascade update,
and I don't have to worry that all the changes that were supposed to happen
actually did. I don't get phone calls from users saying, "I can't find Nancy
Davis in the database. Didn't she get married? Do you know her new last
name?" because the applications those users are working with are keyed on the
surrogate key, not the employee's first and last names, MI and DOB.
I'm wondering who invented immutability as a requirement for primary
keys.
No one I know. I'm guessing it was some former telemarketer, whose last
unemployment check was already spent, was offered a job application at the
unemployment office as either a nuclear waste disposal technician, a belly
dancer or a database theorist, and the first two jobs had really fierce
competition.
Is it based on the relational model (which I doubt)
I haven't read all 333 rules yet, but my guess is that it's in there. Even
if it isn't, there's a logical reason for an immutable primary key. If you
use an immutable, meaningless surrogate key, then the natural key is stored
and updated in only one record in one table. Non-duplication of data is a
goal of relational databases in order to avoid data insertion and data
deletion anomolies, even if Dr. Codd didn't specifically mention immutable
primary keys in his paper in 1970. It was just a theory back then.
When skimming through the article, it seems to me that
inventing characteristics of primary keys so that it excludes natural
keys, is the whole point of the article.
He's trying to prove his point with real world examples. He can't very well
list the high tide times in Hawaii as proof of his point. He needed to
explain the problems he's encountered and had to deal with. I've encountered
many of the examples he describes in his article myself, so I wouldn't agree
that he *invented* disadvantages for natural keys.
Curiously enough, that more or less defines a property/datatype just
like autonumber, identity .... what a coincidence ;-)
You make it sound like these characteristics were invented *after* the
AutoNumber data type was invented, so that these characteristics would
coincide with the attributes of an AutoNumber.
As an aside, with regards to the Jet identity (counter), I'm not sure
I'd dare say this is completely immutable either, or at least I don't
think it qualifies for Lonigros characteristics, as you can reseed it
and reuse the numbers.
Just because you *can* reseed a counter doesn't mean that it's a requirement
for all counters, making this data type inherently unstable and therefore
disqualified for surrogate keys. Why would you reseed a meaningless number
so that you could reuse it in a column that requires unique values? You
wouldn't.
Here's some Oracle guys discussing your article
It's not my article. You asked me to find others who also recommended that
primary keys never change, because my opinion doesn't carry any weight with
you. And as for *Oracle guys,* I see *no* indication that any of the blog
commentators dabble in Oracle.
I'm not sure I want to discuss their discussion, if that was your intention
by offering that link. Their discussion of Mike Lonigro's article mostly
entails Eric's assertions, which I'm reluctant to put a label on. For
instance, Eric starts off by saying the article is full of holes, followed by
his comment about Mike Lonigro's statement, "The primary key, however, is a
physical design element that uniquely identifies rows after they are in the
database":
"No, candidate keys (of which primary keys are
a somewhat debatable subtype) are part of the
relational model, which is purely logical."
Which tells me Eric thinks primary keys aren't in the physical model.
Okaaaay. (None of the other commentators disputed Eric's theory or other
assertions, and just one of them, Gary, stated, "I agree with Eric above.")
Eric's comment on Mike's next statement, "[The primary key] is used in
creating foreign keys in other tables in order to establish the logical
relationships in the data model" is this:
"So a physical element is used to establish
'logical relationships'? Department of
Circularity Department?"
Which tells me Eric is trying to make fun of what he believes is Mike's fatal
error in developing the physical model before designing the logical model.
Okaaaay.
Discussing Eric's comments would seem to be a prelude to a debate on how many
angels can dance on the head of a pin. Please forgive me if I pass on this
intellectual opportunity.