Re: Random Unique Integer - Mailing list pgsql-sql

From Campbell, Lance
Subject Re: Random Unique Integer
Date
Msg-id A3AC4FA47DC0B1458C3E5396E685E63302395E47@SAB-DC1.sab.uiuc.edu
Whole thread Raw
In response to Re: Random Unique Integer  (Michael Fuhr <mike@fuhr.org>)
Responses Re: Random Unique Integer  (Kristo Kaiv <kristo.kaiv@skype.net>)
List pgsql-sql
I have a web application that is used to create web surveys and web
forms.  Users can create any number of surveys or forms at any time.
The primary key on one of my tables defines the ID for any given form or
survey.  I do NOT want the number sequential.  Since I use the number in
the web URL as a parameter, I don't want people guessing what survey or
form is next.  By creating a very large random number the users cannot
easily guess another form or survey's ID.  This number is not designed
for security but to keep people from being nosey and poking around
easily into someone else's form or survey.

Can a table have a primary key that is randomly generated?

Thanks,

Lance Campbell
Project Manager/Software Architect
Web Services at Public Affairs
University of Illinois
217.333.0382
http://webservices.uiuc.edu
-----Original Message-----
From: Michael Fuhr [mailto:mike@fuhr.org]
Sent: Thursday, June 14, 2007 8:26 AM
To: Campbell, Lance
Cc: pgsql-sql@postgresql.org
Subject: Re: [SQL] Random Unique Integer

On Thu, Jun 14, 2007 at 08:08:26AM -0500, Campbell, Lance wrote:
> I have a table T1.  It contains a field called F1.  Is there a way for
> me to set the table T1 up such that F1 can be populated with a random
> integer such that F1 is a unique integer?

What problem are you trying to solve?  The solution might depend
on what you're trying to do.

--
Michael Fuhr


pgsql-sql by date:

Previous
From: "Rodrigo De León"
Date:
Subject: Re: Organization of tables
Next
From: Kristo Kaiv
Date:
Subject: Re: Random Unique Integer