Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best format for a customer number, order number?

A large international company deploys a new web and MOTO (Mail Order and Telephone Order) handling system. Among other things you are tasked to design format for both order and customer identification numbers.

What would be the best format in your opinion? Please list any assumptions and considerations.


Accepted Answer

Michael Haren's answer selected due to the most up votes, but please do read other answers and comments as they make Michael's answer more complete.

like image 962
Vlad Gudim Avatar asked Oct 07 '08 13:10

Vlad Gudim


2 Answers

Go with all numbers or all letters. If you must mix it up, then make sure there are no ambiguous characters (Il1m, O0, etc.).

When displayed/printed, put spaces in every 3-4 characters but make sure your systems can handle inputs without the spaces.

Edit: Another thing to consider is having a built in way to distinguish orders, customers, etc. e.g. customers always start with 10, orders always start with 20, vendors always start with 30, etc.

like image 120
Michael Haren Avatar answered Sep 20 '22 01:09

Michael Haren


DON'T encode ANY mutable customer/order information into the numbers! And you have to assume that everything is mutable!

Some of the above suggestions include a region code. Companies can move. Your own company might reorganize and change its own definition of regions. Customer/company names can change as well.

Customer/order information belongs in the customer/order record. Not in the ID. You can modify the customer/order record later. IDs are generally written in stone.

Even just encoding the date on which the number was generated into the ID might seem safe, but that assumes that the date is never wrong on the systems generating the numbers. Again, this belongs in the record. Otherwise it can never be corrected.

Will more than one system be generating these numbers? If so, you have the potential for duplication if you use only date-based and/or sequential numbers.

Without knowing much about the company, I'd start down this path:

  • A one-character code identifying the type of number. C for customers, R for orders (don't use "O" as it could be confused with zero), etc.
  • An identifier of the system that generated the number. The length of this identifier depends on how many of these systems there will be.
  • A sequence number, unique to the system generating it. Just a counter.
  • A random number, to prevent guessable order/customer numbers. Make this as long as your paranoia requires.
  • A simple checksum. Not for security, but for error checking.

Breaking this up into segments makes it more human-readable as others have pointed out.

CX5-0000758-82314-12 is a possible number generated by this approach . This consists of:

  • C: it's a customer number.
  • X5: the station that generated the number.
  • 0000758: this is the 758th number generated by X5. We can generate 10 million before retiring this station ID or the station itself. Or don't pad with zeros and there's no limit.
  • 82314: this was randomly generated and results in a 1/100,000 chance of guessing a customer ID.
  • 12: checksum.
like image 21
Marty Lamb Avatar answered Sep 20 '22 01:09

Marty Lamb