Posted by Rik on 07/04/06 18:50
Usenet wrote:
>>> I am using MySQL 5 with PHP 5. While running some test
>>> programs, I noticed that it is not necessary to write any code
>>> which ensures that
>>> a field is unique--if the field is defined as a primary key.
>
> It's best not to use primary keys that have been picked by the user.
> Presumably if the user has picked it, it's for a reason. It's quite
> possible that the user will want to change it at some point. Pretty
> hard to do if it's also being used by the system as a key...
>
> Would they expect to be able to change it when it's their login id?
> P'raps not. Still doesn't make it a good thing to do though :-)
Exactly.
I'd us a normal integer autoincrement as primary key, perhaps a UNIQUE index
on username, but I'll always check with PHP. Just makes reporting the errors
back to the user easier.
Grtz,
--
Rik Wasmus
[Back to original message]
|