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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Normalization, Natural Keys, Surrogate Keys

Re: Normalization, Natural Keys, Surrogate Keys

From: Pablo Sanchez <pablo_at_dev.null>
Date: Fri, 17 May 2002 21:11:15 -0600
Message-ID: <3ce5c46b$1_15@news.teranews.com>

"Daniel Morgan" <dmorgan_at_exesolutions.com> wrote in message news:3CE583F3.7F5D20D5_at_exesolutions.com...
> Paul Tiseo wrote:
>
> The reason some people go ballistic is as follows:
>
> CREATE TABLE employees (
> surrogate_key NUMBER,
> ssn VARCHAR2(11));
>
> ALTER TABLE employees
> ADD CONSTRAINT pk_employees PRIMARY KEY (surrogate_key);
>
> CREATE SEQUENCE seq_surrogate_key START WITH 1;

You forgot:

CREATE UNIQUE INDEX ssn ON employee (ssn);

(btw, you should use singular rather than plural for table names. <g>)

> INSERT INTO employees
> VALUES
> (seq_surrogate_key.NEXTVAL '555-55-5555');
>
> INSERT INTO employees
> VALUES
> (seq_surrogate_key.NEXTVAL '555-55-5555');
>
> COMMIT;
>
> It happens all the time.

Clearly.

--
Pablo Sanchez, High-Performance Database Engineering
mailto:pablo_at_hpdbe.com
http://www.hpdbe.com
Available for short-term and long-term contracts
Received on Fri May 17 2002 - 22:11:15 CDT

Original text of this message

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