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: Building a primary key

Re: Building a primary key

From: doid <doid_at_usa.net>
Date: 1997/04/03
Message-ID: <33440540.5994@usa.net>#1/1

In my opinion, this is not a good idea. If two users try to update the table concurrently, a trigger using this algorithm would generate the same primary key for both transactions. I believe that it would be much wiser to use sequences.

mlarson wrote:
>
> You could build a insert trigger that will make the primary key column
> something
> like max(primarykeyfield)+1. This does the same as a sequence without
> the chance of losing alot of values. You can also use the
> DBMS_UTILITY.GET_TIME function in the trigger statement which gives the
> time up to hundredths of a second.
>


In general, I loathe artificial, numeric primary keys. I would prefer to use a real, meaningful value everywhere. One exception would be the case of a multi-column primary key which is referenced as a foreign key. It can often be more convenient to reference a single artificial key than to reference the multi-column key.

Unfortunately, the CASE tool that our data modeller used for our system forced us into artificial primary keys for nearly every table in the schema :( Has anybody else noticed that this can be a problem with some Tools? Are some better than others? (hehe, is Designer 2000 the best?)


The views expressed here are mine and do not reflect the official position of my employer or the organization through which the Internet was accessed. Received on Thu Apr 03 1997 - 00:00:00 CST

Original text of this message

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