Identity key?
Date: Fri, 5 Jan 2001 16:55:24 -0500
Message-ID: <hpr56.114963$Z2.1336437_at_nnrp1.uunet.ca>
Hello,
I have a question regarding an observation made by Joe Celko in an article. Quoting the article:
For example, this was posted on a newsgroup:
CREATE TABLE US_States
(state_id IDENTITY NOT NULL,
state_abbreviation CHAR(2) NOT NULL,
state_name VARCHAR(15) NOT NULL);
The idiot who did this assumed that the IDENTITY column was a key. Those other two columns better be unique or this thing is not going to work. The correct declaration should have been something like this:
CREATE TABLE US_States
(state_code CHAR(2) NOT NULL PRIMARY KEY,
state_name VARCHAR(15) NOT NULL UNIQUE);
Woulldn't be better to have the table like this?
CREATE TABLE US_States
(state_id IDENTITY,
state_code CHAR(2) NOT NULL PRIMARY KEY,
state_name VARCHAR(15) NOT NULL UNIQUE);
TIA, DODO Received on Fri Jan 05 2001 - 22:55:24 CET