Primary Keys

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • TheServant
    Recognized Expert Top Contributor
    • Feb 2008
    • 1168

    Primary Keys

    Hey guys,
    Another thread has inspired me to change the way I run things. At the moment I have a member table etc... The primary key is set as an autoincrement number, however I have obviously made it so that people cannot have the same user name as each other. So am I wasting my time with this? Should I make the primary key the user name?

    If not, how can I autoincrement, but not run the risk of having my id numbers changed if I reorganised for some reason? I am thinking if I want to have a customised autoincrement, I will need to store a number that turns over everytime someone registers and use that as the user number. That way if someone deletes their account the number will not be -1. Is this the way to do it, or is there another common way?
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    I would leave the assigned primary index alone and, in your case, simply make the userid a UNIQUE field. That way you can handle it as a normal field without having to bother about re-indexing etc.

    Ronald

    Comment

    Working...