I'm upsizing a backend MS Access database to SQL Server. The front-end client will remain an Access application for the time being (has about 30k lines of code).
The aim is to eventually allow synchronisation of the database accross multiple servers (not using replication but probably the sync framework).
Currently, all Primary Keys in the Access tables are autoincrement integer surrogates.
I'm not asking about the process of upsizing but about whether I should use GUID or another codification for the PK (I know I could split the number range accross servers, but I don't want to do that and allow the PK to be created on the client if necessary, for instance in Offline mode).
GUID
Pro:
- standardised format.
- uniqueness assured (practically anyway)
Cons:
- not easy to manipulate in Access, especially when using them as filters for subforms or in controls.
- degrade INSERT performance due to their randomness.
- has more than one representation: string, canonical form, binary that need to be converted.
Custom codification scheme
I thought that maybe a scheme using a more uniform code as PK would avoid the performance penalty and, most importantly, ensure that the PK remains usable in form controls where necessary (and not require these conversions to/from string).
My idea for a codification scheme would be along the lines of a 10 character code split into:
- 8 digits for a timestamp
- 4 digits for a unique client ID
- 2 digits as a random number for potential colisions
Each digit would be in base 34, composed of letters from A-Z and 2-9, avoiding
O
,0
,1
,I
because of their similitude (in case we need to manually handle these PK, for instance during debugging).
Pro:
- easier to handle manually when the case arises.
- don't require conversion between different representation since it's basically a string (so less existing code to adapt).
- uniqueness assured (practically)
Cons:
- performance in JOIN hasn't been proven
- performance in INSERT should be faster than GUID but not proven
- Each server/client machine must be set its own UID, although that should not be too much of an issue.
So, should I use GUID or another scheme for my PK?