I'm developing an asp.net application that has some potentially large data tables. I would like to know what would be the best way to define a primary key. I know this has been asked before, but since this is for a specific situation, I think the question is valid.
I'm using Entity Framework 4 on a SQL server 2008 database.
What are the possibilities for defining a primary key, considering the following:
- There is a real possibility that over time the number of records will exceed the 32 bit boundary, so an auto-increment integer will not be possible.
- There is no possibility to define a primary key on a combination of other columns in the table.
- For data synchronization reasons, an application-generated id would be preferable over a database-generated id. Also, in EF it would mean an extra roundtrip to the database to retrieve the newly generated id.
- For insert performance, a sequential key would be preferable.
- I consider the space requirements for a (sequential) guid a downside.
- For string id's, case insensitivity would be preferable.
What I've come up with myself so far is a custom algorithm which generates a datetime part and a random part, converted to a hexadecimal string representation. This leaves me with a slightly shorter string than a guid. I could still convert it to base64, but that would go against item nr 6.
Thanks for your suggestions.