Sequence numbers best practice

Posted by Abdullah Jibaly on Stack Overflow See other posts from Stack Overflow or by Abdullah Jibaly
Published on 2010-03-12T23:59:21Z Indexed on 2010/04/14 3:33 UTC
Read the original article Hit count: 361

Filed under:

What's the best practice or well known methods to implement sequence numbers for business entities such as invoices, purchase orders, job numbers, etc? I want to be able to save the latest value in the database and be able to set it programatically. Is it OK to use a table for this purpose that has a SEQUENCE_NAME, SEQUENCE_NUMBER tuple? I know some databases have a first class sequence type but others (eg, MySQL) do not so it's not something I want to rely on. If a table is used to hold these sequences what is the right way to get and increment them in a synchronized fashion to ensure no data inconsistencies arise?

© Stack Overflow or respective owner

Related posts about database-design