BruceM said:
For my purposes I make sure the PK is unique. If ID is unique, I am done
creating a PK. If I understand correctly, ID is a unique field, and you are
adding the other fields to the PK in the interest of physical ordering on
the disk, but only one field (ID, which is unique in any case) needs to
enter into the relationship.
In my example, yes.
So you would have one field (ID)
for relationships, and add the other fields to the PK for physical ordering
on the disk. Do I understand correctly?
In my example, yes.
If so, is there a performance
advantage (or some other advantage) to enforcing a particular type of
physical ordering on the disk vs. the resource demands of combining multiple
fields to augment a field (ID) that is already unique?
I'll be cautious here: assuming the database file is regularly
compacted, there will be a performance advantage associated with having
a well chosen physical ordering. How significant that advantage may be
will vary due to circumstances, even to the point of what SQL DML you
are using (e.g. GROUP BY and BETWEEN constructs particularly benefit
from sensible clustered indexes).
If you are asking whether there may be a scenario where the overhead of
maintaining the non-clustered index associated with the PK between file
compacts outweighs the performance benefits of a well chosen clustered
index on a regularly compacted file, I'd think it unlikely but wouldn't
rule it out completely (many columns in the PK, more INSERTs than
SELECTs, SQL DML necessitates many table scans, etc). As with any
performance-related issue, you just have to test, test and test again.
If so, is there an
advantage to using all three name fields over using, say, the last name
field alone?
Again, it depends on the SQL DML. If you are using a field/column in
addition to last name then it should at least be considered for
inclusion in the PK.
For my purposes I make sure the PK is unique. If ID is unique, I am done
creating a PK.
So you are not looking for performance benefits. Your choice, no
biggie. My priorities are correct design and ease of maintenance, in
that order. Performance is not a priority for me either... which is why
I'd suggest you think in terms of UNIQUE CONSTRAINT rather than PRIMARY
KEY.
By the way, I am aware that ID is a reseved word
I don't think so but I could be mistaken. I check for reserved words in
Jet 4.0, SQL Server 2000, SQL Server 'future', SQL-92, SQL-99 and
SQL-2003, and 'ID' passes all my filters. Where do you think it is
reserved?
What would you have suggested to the person who posted the original
question?
If asked, I'd suggest the OP uses a SQL DDL script to create schema
elements rather than GUI tools, but I would not proffer such advice to
someone asking about toolbar buttons.