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

Home -> Community -> Mailing Lists -> Oracle-L -> RE: Primary keys

RE: Primary keys

From: Jack C. Applewhite <japplewhite_at_inetprofit.com>
Date: Thu, 07 Mar 2002 14:31:49 -0800
Message-ID: <F001.00422C17.20020307143149@fatcity.com>


Harvinder,

Every table needs a PK. Otherwise, you have no way of identifying a row uniquely.

You also need an index on each FK, to prevent locking problems when updating/deleting the parent table. You can kill two birds with one stone by making your history tables' PKs (enforced by unique indexes) be a concatenation of the FK column(s) - make it(them) the leading column(s) - with at least one more column that produces a unique ID for each row.

Then you've got both a PK and an indexed FK and everyone is happy! ...except maybe your duhvelopers, who are obviously not all that knowledgeable, so who cares if they're happy?!?! ;-)

Jack



Jack C. Applewhite
Database Administrator/Developer
OCP Oracle8 DBA
iNetProfit, Inc.
Austin, Texas
www.iNetProfit.com
japplewhite_at_inetprofit.com
(512)327-9068

-----Original Message-----

Singh
Sent: Thursday, March 07, 2002 11:13 AM
To: Multiple recipients of list ORACLE-L

HI,

We have some history tables that are pointing to parent tables. Parent tables has primary key.
Our developers are saying that we have foreign key from history table to parent table and we don't need primary key on history table. Does there are any benefits if we have primary key(concatenated) on history table. OR
do we should leave history tables without primary key

Thanks
--Harvinder
--

Please see the official ORACLE-L FAQ: http://www.orafaq.com
--

Author: Harvinder Singh
  INET: Harvinder.Singh_at_MetraTech.com

--

Please see the official ORACLE-L FAQ: http://www.orafaq.com
--

Author: Jack C. Applewhite
  INET: japplewhite_at_inetprofit.com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists

--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). Received on Thu Mar 07 2002 - 16:31:49 CST

Original text of this message

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