I have a table like this
user(#id, login, password)
But i want to make it just like
because the login is unique for each user
I want to know if this is a good solution ? it will affect speed (performance) with a primary key with long char (indexes) ?
Best How To :
This is always a fun question. It is actually a long debate in database design, "natural" vs "surrogate" keys.
Since this is question isn't quite a duplicate of just that, I'll put an answer but also some links to the core issue since it is well-covered.
Like most database performance question, it ultimately depends. :)
If your login is short and/or you don't have a large number of logins, you may not see much difference from an integer key.
You might also think about if someone is ever allowed to change their login... if so, you will want the surrogate integer to let you keep the key.
For more about this as a general question, and some other folks' tests on performance:
Deciding between an artificial primary key and a natural key for a Products table
Surrogate vs. natural/business keys