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

Home -> Community -> Usenet -> c.d.o.tools -> Re: primary keys

Re: primary keys

From: Dave Macpherson <dave_at_fifthd.ca>
Date: 1997/06/10
Message-ID: <339d5d56.60602099@news.sas.ab.ca>#1/1

On 8 Jun 1997 18:37:00 GMT, "Aldo Alejandro" <aalejan_at_pacbell.net> wrote:

>Hello everyone,
>
>How would you create primary keys in personal oracle 7.3 using the create
>sequence route?
>Also I would like my pk's to be informative (e.g.) customer order id # is
>today's date + order number
>
>The second case would be creating a pk that uses the concatenation of the
>first four letters of the fname and the first 4 letters of the lname.
>--
>Thanks & have a nice day! ;-)

Aldo...

This is generally considered a bad thing to do. I would try to stay away from so-called "intelligent keys" whenever possible. Using your first example above you should simply define your primary key to be the compound key of ORDER DATE and ORDER NUMBER. For your second example, the combination of first and last name characters probably is a poor choice of primary key (how many John Smith's are there?), and I would instead consider a simple blind numeric key based on an Oracle sequence if no other choice of columns exists to uniquely identify a row within your table.

Regards,

Dave Macpherson Received on Tue Jun 10 1997 - 00:00:00 CDT

Original text of this message

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