#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2010
    Posts
    2
    Rep Power
    0

    Question Primary key choice


    I'm a start to developing an online RPG game, like “Mafia Wars”.

    I'm using :

    Flash + PHP + MySQL

    I have read some larges debates about natural keys vs surrogate keys in forums. I would like to read opinions from game developers.

    What will be a good choice for a primary key : an e-mail, an user-name, or a surrogate key (e.g. database sequence number)

    Thanks.
  2. #2
  3. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,317
    Rep Power
    7170
    For user accounts I always use a surrogate primary key. A username won't change that often, but occasionally you will have someone who wants to change it. E-Mail addresses change even more frequently.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  4. #3
  5. Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2004
    Location
    Switzerland
    Posts
    1,152
    Rep Power
    1902
    I'm a strong advocate of surrogate keys. It leaves you free to change everything else should you ever want to.

    In the worst case you waste some 4 or 8 bytes per entry. In the best case it saves you from a big headache down the line.
    - Hugh of Borg

    The first thing young borg are taught: Keep away from Microsoft software!
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2011
    Posts
    11
    Rep Power
    0
    ZX is a good setup

IMN logo majestic logo threadwatch logo seochat tools logo