friend 告诉我的:
What unique key do you use? I hope you are not saving the entire user name --- this will use up too much table space! Assign an unique userID to each (unique) userNAME and save this userID (should be INTEGER UNSIGNED auto_increment or BIGINT UNSIGNED auto_increment). Don't forget to create a reference
FOREIGN KEY (
userID
) REFERENCESusertable
(userID
) in all tables using the userID.
以上说法正确吗?为什么或为什么不?
最佳答案
我认为他是对的(出于错误的原因),因为主键不能改变,但 username
可以改变。所以你应该使用 userid
因为它不会改变。
关于mysql - 在数据库设计中使用用户名作为主键不好吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1825613/