Best parctice - Auto increment or Natural Key (1 Viewer)

Geirr

Registered User.
Local time
Today, 16:39
Joined
Apr 13, 2012
Messages
36
Hi all.
I've tried to read throug lots of docs on best practice on PK on tables, but....

Background:
For electro company in shipbuilding I'created a backend with several tables, one accdb for each project. Many of exisisting keys in those table are same for each project - due to what they call SFI in ship bulding.
Typically, each 'PK' in access tables have a meaning in the understaning of what it represent, eg. 408.1001.10 (Believe me, this number has a meaning...)

Now, I'm transferring everything to a common SQL server, and I started of using Autincrement fields as PK, due to fact that those where easy to connect n relation, and becaus I where told this is the perfect way. But, it gets more and more clear that using 'meaningfull' ID's in PK would give me better info in stead og 'random' integers.
So, adding a Project indetifier here - normally 5 digits/char would create an PK-info like '12345-404.1001.10' in one of the table. The PK field-info will be generated normally in a field's AfterUpdate.

The question is; will I get big difference in search speed, updates etc using PK with character(up to 30 chars)? Using char-based PK as mentioned gives us a big 'reading' benefit, but I'm afraid that we will loose other important benfits like speed. (search, update etc). Googling this issue have until now given me 50/50 pros and cons each way...

Brg.
Geirr.
 

June7

AWF VIP
Local time
Today, 06:39
Joined
Mar 9, 2014
Messages
5,463
Here we go again. Review https://access-programmers.co.uk/forums/showthread.php?t=305302

You can still have the natural value in table and use the autoincrement as the PK/FK. Purpose of autoincrement PK/FK will be to associate records in queries and linking form/subform and report/subreport. Users don't even need to be aware of them.

Searches can be designed so that user selects the natural value but code will use associated autoincrement.
 

Users who are viewing this thread

Top Bottom