Re: Creating and saving IDs - is there a theory?
Posted in 1997
Topics: Networking & sqlhosts Configuration
In a past life I have used what I think some people call Modulo-11, it works in the following manner for an 8 digit number: multiplier 8 7 6 5 4 3 2 1 number 1 0 0 0 0 0 8 2 5 = (8*3) + (2*2) + (5*1) = 33 number 2 0 0 0 7 5 6 1 2 = (7*5) + (5*4) + (6*3) + (1*2) + (2*1) = 77 number 3 5 6 0 0 4 5 5 x = (5*8) + (6*7) + (4*4) + (5*3) + (5*2) = 123, therefore x = 9 (making 132) ie the sum of the digits multiplied by their position must be divisable by 11. This allows for very quick checking that a number is reasonable, but does not check if it's correct. Lets put it another way, the banks find this an acceptable way for allocating account numbers, so I feel that you can safely use it for allocating serial numbers. You could add in additional checking like using the 5th digit to represent a type, and the 6th a store then you have to check that the store sells the type. Or possibly add a 9th digit that also follows the Mod11 principal, to use the example above: First time 8 7 6 5 4 3 2 1 5 6 0 0 4 5 5 9 = 132 Second time 9 8 7 6 5 4 3 2 1 5 6 0 0 4 5 5 9 = (5*9) + (6*8) + (4*5) + (5*4) + (5*3) + (9*2) = invalid number (166) but 8 7 6 5 4 3 2 1 5 6 0 0 1 1 1 8 = 99 Second time 9 8 7 6 5 4 3 2 1 5 6 0 0 1 1 1 8 0 = (5*9) + (6*8) + (1*5) + (1*4) + (1*3) + (2*2) = 121 I have to admit that I have never tried this (9 digit numbers), the idea is an on the fly brain dump, some matematician can tell me if I've one wrong anywhere. -- Peter Dudley Interactive Innovations P/L interino@ozemail.com.au Klaus Marquardt <"klaus.marquardt "@ draeger.com> wrote in article <5i0dkj$nis@com1.dwhl.de>... > Doug Dumitru wrote: > > "Lior Messinger" <messingr@netvision.net.il> wrote: > > >We are designing a project where we need to create, save and then verify > > >huge amounts of IDs (or serial numbers), for inventory items. We need to do > > >the saving part and the verification very fast, on a server. This is done > > >to verify that the items are not faked. The project is done on NT and Unix. > > >Is there any theory about doing that? > > > > From a purely theoretical point of view, you need an application that can > > maintain a very fast "direct hit" index. Basically, it sounds as though you > > wish to "put something in a store" and then very quickly, determine if the > > something is present. > > > > The most typical way of accomplishing this is with a hashing algorithm. Hashing > > is far and away the fastest indexing method when only direct hits are required > > (as opposed to sequential access). An example of hashing is the lookup > > functions in large TCP/IP routers that get information for a particular IP > > subnet path. This is probably the most extreme example of a lookup needing to > > run quickly.