Thursday 15 September 2011

design - A good algorithm for generating an order number -


As much as I would like to use GUIDs in my system as a unique identifier, it is user-friendly for a field There is no order number where a customer may have to repeat the customer service rep.

  • To optics)
  • Only numeric values ​​(so it can be easily read in CSR or pressed on the phone)
  • & lt;
  • Answers were posted, we decided to make 9-digit numbers in the middle level saved in DB randomly. In case of any confrontation, we will rebuild a new number.
  • If the middle class can not be checked, the "order number" already exists in the database, the best It could be equivalent to generating a random number. However, if you generate a random number which is limited to less than 1 billion, then you should worry about accidental collision on almost sqrt (1 billion) , that is, some thousand entries After the occurrence of the collision, the risk of content is what happens if the serial number is indexed, but in a disguised manner, i.e. some large number of modules 1 billion next to multi- Will meet the requirements?


    No comments:

    Post a Comment