Numberic Field for Lookup

R

Rita

I designed a huge database 10 years ago. I finally am going back and cleaning
things up. There are several tables that I used a text field as a primary
field. I would like to delete the relationships, create an autonumber field
for each table, and recreate the relationships. I have 147 queries though so
it would be a lot of work. Everything works, so would the database run better
using a numberic field? Thanks!
 
A

Allen Browne

For tables where there is a simple, obvious, short, natural primary key, use
it.

For example, if you have a table of categories where each category name is
unique, required, and say 24 characters or less, it makes good sense to use
the category name as the primary key IMHO. IME, there is no practical
difference in performance when using a text-key for these little tables with
<1000 records.

Some developers avoid this because they have generic routines that assume a
particular data type. You do have to remember to add the quote delimters
when matching a value in a text field.

Sometimes the text primary key is really handy, e.g. it avoids some problems
Access has when a combo's bound column is not the display problem:
http://allenbrowne.com/bug-06.html

So, I'm not convinced it would be worth the effort to change them all.

If you do have problems in remembering the data types and sizes for all the
fields in your projects, here's what I use:
Relationship Report with extended field information
at:
http://allenbrowne.com/AppRelReport.html
 
R

Rita

Well that's good to hear! I thought the database ran more efficient if the
foreign keys were numeric. Thanks so much for the Relationship Report with
extended field information!!!! What a wonderful tool!
 
R

Roger Carlson

Well, in theory, it is true that joins based on numeric fields are more
efficient. However, if the difference is milliseconds, the practical
difference to the user is negligible. My experience is that small databases
sometimes become large, and so I develop for the future. But if your users
aren't bothered by the difference, it's probably not worth it to backfill,
IMO. On the other hand, if performance is an issue, that might be one way
to improve it.

--
--Roger Carlson
MS Access MVP
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top