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
https://forums.phpfreaks.com/topic/93862-primary-keys/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.