Re: Primary Keys

From: "Josh Berkus" <josh(at)agliodbs(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andrew Bell <acbell(at)iastate(dot)edu>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Primary Keys
Date: 2001-11-27 16:46:01
Message-ID: web-514320@davinci.ethosmedia.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Andrew,

> > Can someone tell me what advantage there is to creating a table
> with a
> > primary key rather than simply adding a unique index to the table
> at a
> > later time.

If you are a serious DBA, one of the important rules to follow is "Never
create any table without a Primary Key." One can achieve the same
result by adding a UNIQUE index on a NOT NULL column later, but the
danger is that you'll forget and go into production with an un-keyed
table. Believe me, I've done it, and didn't realize what was wrong
until I got a "Could not identify unique tuple" error.

For an extensive discussion of why primary keys are important, see
"Practical Issues in Database Management" (F. Pascal).

-Josh Berkus

______AGLIO DATABASE SOLUTIONS___________________________
Josh Berkus
Complete information technology josh(at)agliodbs(dot)com
and data management solutions (415) 565-7293
for law firms, small businesses fax 621-2533
and non-profit organizations. San Francisco

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Stephan Szabo 2001-11-27 16:57:05 Re: [HACKERS] upper and lower doesn't work with german
Previous Message Vincent.Gaboriau 2001-11-27 16:08:31 Re: [HACKERS] upper and lower doesn't work with german