I'd like to create some human-friendly codes to identify my objects.
I'm thinking about using the following rules:
- 6-digit random number
- the first character is not zero
- each code has an edit distance value of 2 or greater* from every other such code
- maybe a checksum too
I'd like my MS SQL database to enforce that the codes I use are not only each unique, but also conform to the above criteria too.
How would I write a database check constraint to enforce rules such as these?
How could I make the database use such numbers as default values for inserted rows?
*so a single keystroke typo won't retreive a different-than-intended record