boen_robot Posted June 16, 2012 Share Posted June 16, 2012 It would be a bad idea to use username as a key if there is any chance of a user changing it.Not really... I mean, even if you use it as a foreign key in another table, there's an "ON UPDATE" action you can define on the foreign key.Every forum I've ever seen uses user numbers as the key to their member database. There must be a good reason for that.Yes, though data integrity is not it. Space and efficiency on INSERTs and UPDATEs are. Link to comment Share on other sites More sharing options...
jimfog Posted June 18, 2012 Author Share Posted June 18, 2012 As a sidenote, I use PHPMyAdmin to handle the database. I have set the primary key the username-sth I wish to change now. The question is does anyone know how to unset that.Or do I have to delete the username field and recreate it without setting it as primary key? Link to comment Share on other sites More sharing options...
boen_robot Posted June 18, 2012 Share Posted June 18, 2012 When using PHPMyAdmin, I think it's a matter of a checkbox next to the column(s) you wish to be the primary key. So, if you decide to change the primary key, you need to first create the appropriate column that will become a primary key, and then change the checkbox accordingly.In terms of SQL syntax, I think it's something like "ALTER TABLE `users` ADD CONSTRAINT PRIMARY_KEY (`new_primary_key_column`)". Link to comment Share on other sites More sharing options...
jimfog Posted June 18, 2012 Author Share Posted June 18, 2012 Thanks-I did it the way you proposed it.. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now