Indexes - Primary key naming conventions 
Author Message
 Indexes - Primary key naming conventions

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?



Wed, 16 Apr 2003 00:01:29 GMT  
 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.



Tue, 22 Apr 2003 02:48:36 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Joined Primary Key in Foxpro (Make 1 Primary Key from 2 fields)

2. Duplicate Value in Index/Primary Key Error

3. Primary Key - Index Problem.

4. Help, Concatenated Indexes (primary keys)

5. Having Problems with concatenated indexes (primary keys)

6. Help, Concatenated Indexes (primary keys)

7. Primary Key Indexes

8. Using a GUID as a Primary Key or indexing a GUID

9. unique primary keys (indices)

10. Substituting names for Primary Keys in forms

11. How to update foreign and primary keys that with the same name

12. Get the Primary key field name

 

 
Powered by phpBB® Forum Software