View Single Post
  #16  
Old September 26th, 2005, 08:13 AM
external usenet poster
 
Posts: n/a
Default


Amy Blankenship wrote:
What are the dangers of using an autonumber field as the code for a code
values?
eg can the autonumber field get set to a differnet value if I have to
re-load the table.


I'm not sure what you mean by "re-load" the table.


If the OP meant this ...

CREATE TABLE Employees (
employee_ID COUNTER,
last_name VARCHAR(35) NOT NULL,
first_name VARCHAR(35) NOT NULL
);

INSERT INTO Employees (last_name, first_name)
VALUES ('Smith', 'John');
-- John Smith gets employee_ID = 1

DELETE FROM Employees;

INSERT INTO Employees (last_name, first_name)
VALUES ('Smith', 'John');
-- The same John Smith gets employee_ID = 2

.... then they are correct: an autonumber can never be a true key
because the same entity gets a different key value depending on when
they were entered into the system (relative order of INSERT).