Re: Random Unique Integer

From: "Campbell, Lance" <lance(at)uiuc(dot)edu>
To: "Michael Fuhr" <mike(at)fuhr(dot)org>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Random Unique Integer
Date: 2007-06-14 19:40:56
Message-ID: A3AC4FA47DC0B1458C3E5396E685E63302395E47@SAB-DC1.sab.uiuc.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)fuhr(dot)org]
Sent: Thursday, June 14, 2007 8:26 AM
To: Campbell, Lance
Cc: pgsql-sql(at)postgresql(dot)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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Kristo Kaiv 2007-06-14 20:58:28 Re: Random Unique Integer
Previous Message Rodrigo De León 2007-06-14 15:22:08 Re: Organization of tables