Re: Re: Mapping output from a SEQUENCE into something non-repeating/colliding but random-looking? - Mailing list pgsql-general

From Bill Moran
Subject Re: Re: Mapping output from a SEQUENCE into something non-repeating/colliding but random-looking?
Date
Msg-id 20090501094448.254f2d81.wmoran@potentialtech.com
Whole thread Raw
In response to Re: Re: Mapping output from a SEQUENCE into something non-repeating/colliding but random-looking?  (Craig Ringer <craig@postnewspapers.com.au>)
List pgsql-general
In response to Craig Ringer <craig@postnewspapers.com.au>:

> Bill Moran wrote:
>
> > Sounds like you're reinventing message digests ...

[snip your comments about why I was wrong about MDs working]

> So long as I don't call it "xor encryption" ... sigh.
>
> > Most of the systems I've seen like this do one of a few things:
> > * Start with an arbitrary # like 1000
> > * Prepend the date (pretty common for invoice #s) like 20090501001
> > * Just start with #1 ... I mean, what's the big deal?
>
> I'm not the one who cares. Alas, I've been given requirements to
> satisfy, and one of the major ones is that customer numbers in
> particular must be non-sequential (as close to random-looking as
> possible) and allocated across a large range.

Why not just grab random values for that one, then?  Just generate
a random value, check to ensure it doesn't already exist ... rinse
and repeat if it's a duplicate.  I mean, how often is this system
adding new customers?

Another trick with the invoice #s is to prepend them with a subset
of the client ID.  You could also use the same technique ... generate
a random value, repeat if it already exists ...

--
Bill Moran
http://www.potentialtech.com
http://people.collaborativefusion.com/~wmoran/

pgsql-general by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: Re: Connecting to a postgreSQL database with windows CE over wi-fi; failing gracefully
Next
From: Sam Mason
Date:
Subject: Re: ERROR: syntax error at or near "IF"... why?