php - For a consumer website, should I have a user ID in my DB in addition to the user-selected unique username? -
this "web dev best practice" question. envisioning website users sign username select (revolutionary, know). enter valid email address. test uniqueness of in db before allowing sign-up.
the site non-commercial in nature, , don't need guid.
given this, should have in db separate user id? understand vaguely mysql might index more efficiently number-based id?
alternatively, should use email address unique identifier?
thanks.
jdelage
user names typically not unique, , e-mail addresses can reused. that's 1 reason have numeric unique user id.
another when create database relation, mysql has make copy of primary key of user table. example, if have list of orders per customer. order contain username if primary key. usernames longer integers, hurts index performance.
if combine two, user changes username or email becomes big problem: have rename primary key, isn't easy, , you'd have update references user other tables.
but overall, eh, hope have bigger things worry about, adding functionality attract users :)
Comments
Post a Comment