Re: Autonumber in Oracle

From: (wrong string) és Lopehandía Marticorena <alopehan_at_auge.cl>
Date: Fri, 24 Sep 1999 13:20:23 GMT
Message-ID: <01bf068f$94d5e900$0601000a_at_Andres.auge.cl>


Craig Ledbetter <craigl_at_gte.net> escribió en artículo <jHDG3.1704$J72.50961_at_dfiatx1-snr1.gtei.net>...
> Mike,
> Several others have already suggested using a sequence for the autonumber
> functionality similar to MS Access. I wanted to address the second part
of
> your question.
> There are advantages to using a real column value as PK if the value
meets....
> [original text deleted]

All the above is true. But usually not all the entities have a code or something similar that lets you define a single column primery key. In a theorical database model you can even use a long raw column as the primary key and it is posible to use as many columns as necesary to define it. Instead, in real world systems the primery key must be as small (in bytes) as posible. This is very important in those tables that will be reference a lot of times by a lot of diferent tables. This issue force you to use arbitrary internal number instead of the primary key the finall user uses.  This is very common in those entities that for some reason are not codified in the business where you are building your application.

Another problem of using user data as the primary key are one of the following:

  • In some cases the user allows entities with the "code" as a null.
  • Some time the code is unknown when the user enters the data. The code is generated later.
  • Errors when puting data into the database are common. If you let the user enter the primary key, then you must consider the cased when a wrong primary key value is entered.

That's all,

                Andrés. Received on Fri Sep 24 1999 - 15:20:23 CEST

Original text of this message