Microsoft Access Forums

Go Back   Microsoft Access Forums > Access Forums > Database Design

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 05-08-2009, 07:23 AM
bar tomas bar tomas is offline Windows XP Access 2003 (version 11.0)
Novice
 
Join Date: Apr 2009
Posts: 5
bar tomas is on a distinguished road
Default Are text primary keys less efficient than autonumbers?

Hi,
In one of my tables I have a column that is a kind of tracking number for a product. It is the primary key of the table composed of a string of numbers (date+ id product+ id person processing order, etc) that I have defined as a text, because it is too long to be declared as an integer.

- Is a text primary key less efficient than an integer one?
- Is it safer (for database integrity) to have a autonumber primary key?

Thanks very much.
Reply With Quote
  #2  
Old 05-08-2009, 07:44 AM
Matrix Matrix is online now Windows XP Access 2003 (version 11.0)
Admin
Can you help (Office)? user definied fields (not available)
 
Join Date: Jan 2005
Posts: 80
Blog Entries: 1
Matrix is on a distinguished road
Default

Yes, integer primary key is always a better option. To me, it's the only option. Auto-number primary key is better than the tracking number in your project, IMO.

The performance is better, also with auto-number primary key, there won't be any ambiguity no matter how your business logic changes, or how big you DB becomes
in the future. I can see only benefits. Probably the only loss is a few extra lines of code.

Reply With Quote
  #3  
Old 05-11-2009, 07:18 AM
bar tomas bar tomas is offline Windows XP Access 2003 (version 11.0)
Novice
 
Join Date: Apr 2009
Posts: 5
bar tomas is on a distinguished road
Default

Thanks a lot for your reply.
When you say that performance is better with an Auto-number primary key, what exactly do you mean? Is it that indexing and querying is more efficient? Why is that?
Thanks very much again for your help.
Reply With Quote
  #4  
Old 05-11-2009, 07:23 AM
Matrix Matrix is online now Windows XP Access 2003 (version 11.0)
Admin
Can you help (Office)? user definied fields (not available)
 
Join Date: Jan 2005
Posts: 80
Blog Entries: 1
Matrix is on a distinguished road
Default

Integer must be faster than string for index, search and other database queries, thus the performance is better. Sorry, I don't know how to explain further.
Reply With Quote
  #5  
Old 05-11-2009, 07:37 AM
bar tomas bar tomas is offline Windows XP Access 2003 (version 11.0)
Novice
 
Join Date: Apr 2009
Posts: 5
bar tomas is on a distinguished road
Default

Thanks a lot!
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Primary Key change macro? gracin Access 0 03-06-2009 07:59 AM
Select "autonumbers" not in sequence jerry525 Queries 5 11-09-2008 11:48 AM
database structure:primary key debate MUKUDU99 Database Design 0 08-18-2008 10:20 PM
reset primary key emilylu3 Access 1 12-09-2005 12:27 PM
do all primary keys use autonumber k Database Design 4 11-22-2005 06:32 AM


All times are GMT -8. The time now is 02:47 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.