
Indexes - Primary key naming conventions
Quote:
> Having just been through a set of tables checking for duplicate index
fields
> (forget to mark an index as primary key and you end up with two indexes on
> the same field, one of which is primary) I am wondering if there is a
useful
> convention for naming them.
> By default Access will use "PrimaryKey" unless you have already given a
> specific name. But if all tables have a "PrimaryKey" index they become
> indistinguishable when separated from their table name.
> Is there a programming / user advantage to having them all named
> "PrimaryKey" or are there better alternatives such as "PK" & fieldname(s)
> etc?
Well, when you have to deal with a primary key, i.e. a "key icon" is visible
for
that field, an index is automatically created (it's necessary). I have a way
to
distinguish primary keys with other fields : primary key field name always
uppercase (for instance, "CUSTOMER_ID"). It's much easier for creating
relations in a visual way. When you set an index on another field of any
table,
for speed reasons or frequent access, you can use the same name of the field
with
a little modification (for instance field name State would be State_i.).
Please don't
use a preceding "_" (like _State) because it's often used to distinguish
metatables, i.e.
tables used by the database system itself. Of course, we can imagine
multiple combinations
to distinguish fields.
You are right to avoid duplicated indexes, because it dramatically slows an
application,
and it's really hard to determine at design time. Tests are often the best
way at the
end of development. Have a nice development.
Pascal.