PDA

View Full Version : Ensure Concurrency in database application



Narayana
09-04-2006, 04:59 PM
Hi,

:ee: :ee: :ee: :ee: :ee: :ee:
I'm back again to this section.

I'm doing a simple website(hosted on LAN - one server, 5 or 6 systems connected to it). It has a form which accepts details of a new user, and then saves these details to a mysql database. I want to assign each new user a unique ID, starting from say, 1000. I want to assign the IDs sequentially for each user.

I plan to find the MAX of the user-id column each time a form is submitted, and return the next higher value. All the 6 computers connected to the server may submit the registration form at the same time. Should I ensure that no two users are given the same ID?? Or will it work out correctly?

:Ksp: :Ksp:

Thanks! :b:

ns80
09-04-2006, 06:02 PM
All the 6 computers connected to the server may submit the registration form at the same time. Should I ensure that no two users are given the same ID?

Yes you should in a multiuser environment. I was told you should use threads for such a situation. I havent tried out. But I think each database connection is a thread. Based on the thread priority, you can arbiter which one gets to insert first :think: This was for ASP.NET, but donno what you are using there.

Morover if the uid is a primary key/unique key of the table. would it generate a duplicate identity value at the first place :think:

Narayana
09-05-2006, 02:05 AM
Morover if the uid is a primary key/unique key of the table. would it generate a duplicate identity value at the first place

yes, i guess there will be an error...
Haven't started doing it, but thought this isue may arise...

asp illai, i'm using php. And mysql.