Search code examples
uuid

Is it possible to make an better unique id as using this rule?


I'm trying to make an better unique id format

because I encountered cases that made same unique id by using following format

(many user tried to connect to our system in a short time)

unique id format is

  1. A class of document sort (2 digits)
  2. B class of document sort (2 digits)
  3. C class of document sort (2 digits)
  4. Department Code (5 upper case alphabet)
  5. yyyyMMddHHmmssSSS (event date and milisecond, 17 digits)
  6. random digit (2 digits)

example 01-27-35-MYDEP-20220115133592028-30

The area that we can modify is 6).

So my idea is

  1. remove random digit area and expand event time (HHmmssSSS -> HHmmssSSSSS) 1/1000 sec -> 1/100000 sec

  2. random 2 digits -> random 2 (digits and alphabets)

1/10*10 -> 1/36*36 = 1/100 -> 1/1296

How's your ideas?


Solution

  • Expanding the time sounds like the best solution, as long as you cannot modify anything else in the identification string. Otherwise I'd suggest UUID.