![]() |
|
|
#1
|
|||
|
|||
|
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. |
|
#2
|
|||
|
|||
|
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. |
|
#3
|
|||
|
|||
|
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. |
|
#4
|
|||
|
|||
|
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.
|
|
#5
|
|||
|
|||
|
Thanks a lot!
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
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 |