March 29th, 2010, 02:23 AM
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)
March 29th, 2010, 07:29 AM
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.
March 29th, 2010, 10:06 AM
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!
June 30th, 2011, 10:22 AM