Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Normalization, Natural Keys, Surrogate Keys
"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 contractsReceived on Fri May 17 2002 - 22:11:15 CDT
![]() |
![]() |