x12

generating 9 digit ids without database sequence


I'd like to create 9-digit numeric ids that are unique across machines. I'm currently using a database sequence for this, but am wondering if it could be done without one. The sequences will be used for X12 EDI transactions, so they don't have to be unique forever. Maybe even only unique for 24 hours.

My only idea:

  1. Each server has a 2 digit server identifier.
  2. Each server maintains a file that essentially keeps track of a local sequence.
  3. id = + <7 digit sequence which wraps>

My biggest problem with this is what to do if the hard-drive fails. I wouldn't know where it left off.

All of my other ideas essentially end up re-creating a centralized database sequence.

Any thoughts?


Solution

  • If HD fails you can just set new and unused 2 digit server identifier and be sure that the number is unique (for 24 hours at least)