From: | "Merlin Moncure" <mmoncure(at)gmail(dot)com> |
---|---|
To: | "Craig A(dot) James" <cjames(at)modgraph-usa(dot)com> |
Cc: | pgsql-performance(at)postgresql(dot)org |
Subject: | Re: Basic Q on superfluous primary keys |
Date: | 2007-04-16 15:55:29 |
Message-ID: | b42b73150704160855s676a8c43n7ef4282f5ef175c9@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
On 4/16/07, Craig A. James <cjames(at)modgraph-usa(dot)com> wrote:
> Merlin Moncure wrote:
> > Using surrogate keys is dangerous and can lead to very bad design
> > habits that are unfortunately so prevalent in the software industry
> > they are virtually taught in schools. ... While there is
> > nothing wrong with them in principle (you are exchanging one key for
> > another as a performance optimization), they make it all too easy to
> > create denormalized designs and tables with no real identifying
> > criteria, etc,...
> I can't recall ever seeing a "natural" key that was immutable. In my business (chemistry), we've seen several disasterous situations were companies picked keys they thought were natural and immutable, and years down the road they discovered (for example) that chemical compounds they thought were pure were in fact isotopic mixtures, or simply the wrong molecule (as analytical techniques improved). Or during a corporate takeover, they discovered that two companies using the same "natural" keys had as much as 10% differences in their multi-million-compound databases. These errors led to six-month to year-long delays, as each of the conflicting chemical record had to be examined by hand by a PhD chemist to reclassify it.
while your example might be a good case study in proper
classification, it has nothing to do with key selection. it is
especially unclear how adding an integer to a table will somehow
magically solve these problems. are you claiming that a primary key
can't be changed?
mutability is strictly a performance argument. since RI handles
cascading primary key changes, it's simply a matter of if you are
willing to wait for RI to do its work or not (if not, swap in the id
key as in my example). the performance argument really only applies
to specific cases, and can be considered a attribute of certain
tables. extraordinary cases do happen, like a company overhauling its
numbering systems, but such cases can be dealt with by a number of
methods including letting RI do its thing.
merlin
From | Date | Subject | |
---|---|---|---|
Next Message | Ron Mayer | 2007-04-16 18:24:15 | Re: Basic Q on superfluous primary keys |
Previous Message | Craig A. James | 2007-04-16 15:02:24 | Re: Basic Q on superfluous primary keys |