Jump to content

Primary Keys..


EchoFool

Recommended Posts

Hey, i need help with a table i am using for trade system..

 

I want to put a "ID" field but i need it to be blank for a while until a certain event, then i need it to insert a unique ID. So it acts as a primary key. But i can't set it as primary key because there could be many rows set to "0" for a while before the field has been updated to a unique ID.... how can i get it to act only as a primary key once a value in a different field equals something?

 

I have a table like this just so you can get what i mean:

UserID | RequestID | Wait | RecordID |

 

 

Now the "UserID" requests to a user on the site .. that user goes in RequestID.

Then Wait is a field to tell the user what the situation is. So if Wait is changed to '1' from '0' then the RequestID user has accepted "UserID"s offer.

At that point when the user "accepts" the request, that is when i need to insert a RecordID. That recordID is like a unique token to represent the ID of the transaction that they are both going to do but it must be unique every time.

This is why i put primary key at first but then realized if i do that they can't all have 0 before hand, because it has to be unique when primary key...

 

Any one got any suggestions on how I should do this without the risk of 2 transactions having the same ID?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.