tags:

views:

78

answers:

3

I am working on a project that requires documents to be associated with customers accounts. Each document must have a unique identifier. The scheme I am working on is in the format AAA-####. The alphanumeric part of the identifier will allow to track a date using three letters (vowels will be dropped to prevent obscene or offensive words). The scheme is good for about 21 years, providing no more than 9999 documents come in one day. The first two characters capture the serial date in a year, using 21 letters in the alphabet(dropping vowels) yields 21^2 which is more than enough to capture the day of the year. The last alphanumeric character captures the year. Which again, limits the scheme to 21 years. I wonder if anyone has implemented a similar type of scheme and what techniques have been used.

+1  A: 

What if the same user uploads the same file? I don't see you autoincrementing anything here. Do you have a fixed width requirement? I have implemented a similar scheme but I have dropped vowels and simply appended the epoch time to the file name. If you enter the file name into a database you can rely on it to create and autoincrement a unique identifier. So your question becomes how do convert their filename to a fixed width identifier? I would suggest allowing the user to select the identifier himself and using a database to check for uniqueness. Constraining the user to a fixed width text field is a poor practice inflicted by programmers on the rest of the world.

ojblass
Yes, the number shall not be longer than 7 characters. Users will type this number to find documents in the system.
+1  A: 

Day of year is timezone dependent. If you have users cross multiple timezones, your naming scheme may not work.

Journeyman Programmer
A: 

If instead of incrementing the last letter by year, you use all three to represent day and just count up from a fixed date, you can make it good for 25 years, instead of 21.

Adrian Archer