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

From: Bill Moran <wmoran(at)potentialtech(dot)com>
To: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
Cc: Jasen Betts <jasen(at)xnet(dot)co(dot)nz>, pgsql-general(at)postgresql(dot)org
Subject: Re: Re: Mapping output from a SEQUENCE into something non-repeating/colliding but random-looking?
Date: 2009-05-01 13:44:48
Message-ID: 20090501094448.254f2d81.wmoran@potentialtech.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

In response to Craig Ringer <craig(at)postnewspapers(dot)com(dot)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/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Dimitri Fontaine 2009-05-01 14:03:40 Fwd: triggers and execute...
Previous Message Peter Geoghegan 2009-05-01 13:29:48 Re: Re: Connecting to a postgreSQL database with windows CE over wi-fi; failing gracefully