Oracle FAQ Your Portal to the Oracle Knowledge Grid

Home -> Community -> Mailing Lists -> Oracle-L -> Re: The Case Against Compound/Natural Keys

Re: The Case Against Compound/Natural Keys

From: Niall Litchfield <>
Date: Sat, 27 Jan 2007 15:23:06 +0000
Message-ID: <>

Well first up natural vs synthetic is a rather religious argument. My observations are the, perhaps apparently contradictory.

  1. Really well designed applications tend to have 'natural' keys.
  2. Badly designed applications also tend to have natural keys.

It sounds rather like you might be falling into the latter category.

In a well designed application careful thought is given to the entities involved, what properties they have that you are interested in and how they relate to each other, either logically or in terms of the rules of the model (aka business rules). When you do this the 'natural' key will tend to fall out of the analysis.

In other applications tables tend to be thrown in one after another to meet changing application requirements, to have columns added and deleted almost at whim and to have a changing definition of what it is that the developer is interested in from the table. Sometimes the table ends up fulfilling an entirely different purpose altogether than it's original one.

I'd not be arguing for or against the choice of natural vs surrogate but for a rational process of design. Adding a field to a primary key because the data arriving as the primary key is non-unique seems daft to me, surely you throw out the duplicates at the load stage. I can however almost guarantee that if you get a surrogate key, they'll still want a second unique index and will want to add fields to it in the event of non-uniqueness.

On 1/27/07, Don Seiler <> wrote:
> I've been on a crusade against my developers lately after having had
> enough of fields being added to already-insane primary keys.
> Today I was given a script to add a field to make what is now a
> 15-field primary key, all natural data. The first 9 fields of the key
> also provide the foreign key into the parent table (although a foreign
> key constraint is, of course, not used), and it carries on down the
> line, growing worse and worse. They've all heard me calling for
> surrogate keys, but they say they need uniqueness among this set of
> fields. Then when they discover duplicates, they just add another
> field.
> I even suggested having NO primary key, just a non-unique key on the
> first 4 or 5 fields. But again they say they need to guarantee
> uniqueness. These tables are bulk-loaded and can contain over 150
> million records. There is no query that even comes close to utilizing
> these fields, it is purely a unique constraint. However, since a
> unique constraint also creates an index, I didn't see any advantage
> there.
> I'm looking for the words to basically doom this practice once and for
> all. I've already told them about the degradation of normalization,
> the storage needed for these unused indexes, etc. They claim there's
> nothing they can do for now. Migrating to surrogate keys would be
> non-trivial and isn't a priority, it seems.
> --

Niall Litchfield
Oracle DBA

Received on Sat Jan 27 2007 - 09:23:06 CST

Original text of this message