Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Are primary keys always needed?

Re: Are primary keys always needed?

From: Brian Peasland <peasland_at_email.msn.com>
Date: Thu, 20 May 1999 22:24:44 -0500
Message-ID: <#JaNynzo#GA.171@cpmsnbbsa03>


>1. Are there any cases in which a primary key is not required for a
>table? Or, Is there any good justification for having a table with NO
>primary key?

A primary key (PK) is never required, but always desired. As many DBAs say, "without PKs and corresponding foreign keys (FK), your database isn't very relational is it? "

You can define tables without PKs. Besides uniquely identifying a record in the table, they also help speed up your searches (if you are searching on the field). The only justification I've ever heard of not having a PK goes like this: When you have a PK, an index is created for that field. If you are inserting lots of records into a table in one mass operation, each record has to wait for the index to be updated before the next record can be processed. To speed up the mass loading of these records, some DBAs find it desireable to drop the PK constraint, load the records (they'll load much faster since they don't have to update the index), and then recreate the PK constraint.

I've also ignored PKs when creating quick, temporary tables.

>2. If a data model as some tables with no primary keys, does this mean
>that the model is NOT a GOOD data model, or is NOT AS GOOD AS it could
>be?

NOT AS GOOD AS IT COULD BE. This generally means that you haven't done a good job of normallizing your tables. I'm not a firm believer that every table should be in Third Normal Form, but you should strive for it unless reasons dictate otherwise.

Hope this helps,
Brian Peasland
peasland_at_msn.com Received on Thu May 20 1999 - 22:24:44 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US