BruceM said:
In table design view there is a data type column. One of the choices there
is autonumber.
Integer is a
field size property for Number data type.
If we are talking about Jet databases, there is a COUNTER data type
which is an incrementing INTEGER by implication. If you are referring
to MS Access applications, there is an autonumber feature that is
subtly different e.g. supports other numeric data types, random
progression, etc. Autonumber is exposed to Jet as IDENTITY but choosing
a data other than INTEGER will result in the loss of incrementing
functionality outside of the MS Access UI.
So the MS Access UI describes autonumber as a 'data type' and its
numeric data type as a dependent property, rather than the other way
round? Counterintuitive to me but no doubt makes sense to countless
others <g>. Of course, just because the MS Access UI says something it
doesn't mean it is true. To use a pertinent example, I recall seeing
this message: "A table must have a primary key for you to define a
relationship between this table and other tables in the database."
However, I can define a foreign key, which has stricter rules than an
MS Access 'relationship', using a column with a unique constraint. It
lies, it lies ...
NameID IS a unique value.
But your autonumber still doesn't provide you with an identifier. I
guess you are using an autonumber because you could have more than one
'Jean Dupont' so the it breaks duplicates. However, you will still not
be able to tell one 'Jean Dupont' row from another unless you expose
your autonumber values to users, which is a bad idea (e.g. there are
better identifiers than random/incrementing numeric values).
What purpose is served by creating another?
Let's go back to basics. If all you want is a NOT NULL UNIQUE column,
why not just declare it as NOT NULL UNIQUE? Why are you using the term
PRIMARY KEY?
If there
are studies demonstrating that use of an autonumber (or number) PK
is ill-advised for performance reasons I would be interested in seeing
them.
Here's one you can do at home with a paper copy telephone directory.
Study exercise1: get a list of phone numbers for names beginning with
the letter A. Study exercise 2: get a list of phone numbers beginning
with the number 1 (after area codes etc). Why is exercise 1 so much
easier than exercise 2? Because the physical ordering is on name. And
why is a paper copy directory ordered on name? Because this is how most
people use the directory.
The same applies to the pages in a database table i.e. there is a
performance advantage if the physical order matches your usage. Using
an autonumber as a primary key would be like a the paper copy telephone
directory ordered by telephone number with the associated degradation
in performance.
If you are looking for something more 'official', try these:
Jet 3.0 Performance Overview (search for each appearance of the text
'cluster'):
http://www.microsoft.com/AccessDev/Articles/v3perf.htm
New Features in Microsoft Jet Version 3.0 (start reading from 'New
compacting method'):
http://support.microsoft.com/default.aspx?scid=kb;en-us;137039
ACC2000: Defragment and Compact Database to Improve Performance (key
phrase = 'Clustered Indexes'):
http://support.microsoft.com/default.aspx?scid=kb;en-us;209769
Jamie.
--