Re: IS it a good practice to use SERIAL as Primary Key? - Mailing list pgsql-general

From Ron Johnson
Subject Re: IS it a good practice to use SERIAL as Primary Key?
Date
Msg-id 456B4168.9000109@cox.net
Whole thread Raw
In response to Re: IS it a good practice to use SERIAL as Primary Key?  (John McCawley <nospam@hardgeus.com>)
Responses Re: IS it a good practice to use SERIAL as Primary Key?  ("Joshua D. Drake" <jd@commandprompt.com>)
List pgsql-general
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 11/27/06 12:53, John McCawley wrote:
>
>> Yes, that's the point.  They are legacy designs, and that portion of
>> the design is wrong.
>>
>>
>>
> I'll weigh in my my .02 on this subject.  After much pain and agony in
> the real world, I have taken the stance that every table in my database
> must have an arbitrary, numeric primary key (generally autogenerated).
> I have found that this gets me into a lot of arguments with other
> database guys, but never seems to cause any problems for me.
> Conversely, I have seen innumerable problems in the real world caused by
> the usage of actual data as primary keys.
>
> Perhaps I am amazingly ignorant, but I have yet to find a case where my
> approach causes any real problems.  What does using "real" data as a
> primary key buy you?  The only real advantages I can see are that an
> individual record's data will be somewhat more human-readable without
> joining to other tables, and that your search queries can be simpler
> because they don't have to join against other tables.

Joshua Drake wrote an interesting blog article earlier this year
about what happened when a firm he was contracting for dropped the
natural key on an important table and retained only the synthetic
key.  Unfortunately I can't find it... :(


> On the (many) occasions that I have worked on databases with "real" data
> as primary keys, I just saw so many problems arise.  In the real world,
> data changes, even supposedly unchangeable data.  When using arbitrary
> primary keys, all you have to do is change the data in the one table
> where it lives.  If you are using real data as your keys, you have write
> complex queries or code to "fix" your data when the supposedly
> unchangeable data changes.
>
> Anyway, I'm sure this is a huge argument, but that's my 0.2

- --
Ron Johnson, Jr.
Jefferson LA  USA

Is "common sense" really valid?
For example, it is "common sense" to white-power racists that
whites are superior to blacks, and that those with brown skins
are mud people.
However, that "common sense" is obviously wrong.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)

iD8DBQFFa0FoS9HxQb37XmcRAt8ZAJ40c0KtB8zHifTymcsa/PBLwWkEuACfQ+dD
K+4NNU7m0RNTQLgeP9pNaqQ=
=SH10
-----END PGP SIGNATURE-----

pgsql-general by date:

Previous
From: Ron Johnson
Date:
Subject: Re: IS it a good practice to use SERIAL as Primary Key?
Next
From: "Brandon Aiken"
Date:
Subject: Re: IS it a good practice to use SERIAL as Primary Key?