Subject RE: [firebird-support] Unique keys without gaps (was: Key violation on Primary/Unique key constraint INTEG_55/30 on table(s) )
Author Helen Borrie
At 11:44 PM 14/03/2006, you wrote:
>On Tue, 2006-03-14 at 12:21 +0000, Si Carter wrote:
> >
> >
> > > -----Original Message-----
> > > I have a question: How can I get straight numbers without
> > > gaps safely?
> >
> > Why would you want to unless this is for invoicing or something
> > similar?
> >
>Sarbanes Oxley - accounting standards.

But you would NOT use numbers that are subject to external
constraints as keys. No accounting standard is allowed to override
best practice in database design. Invoice numbers that are subject
to a business rule that requires contiguity carry semantic meaning
and therefore violate a vital consistency/durability rule if used as
primary keys.

You *can* maintain unbroken (or, rather, auditable) series for use to
satisfy a business rule, and store them as a non-key or alternate key
column. There are various ways to achieve that - and incrementing
the Max(SacredNumber) is not one of them. Just as tinkering with
generators is not one of them.

If you'd like to read a paper on the subject, see
www.ibobjects.com/TechInfo.html, "An Auditable Series of Numbers".

./helen.ACID-police