I have a table that stores user info.
In the User table, username is unique. Do you think I should make username as primarykey or should I use a surrogate key that is an int?
Would using a string key hit performance badly?
I have a table that stores user info. In the User table, username is
Share
Use a surrogate integer key.
Usernames won’t change that often, but they could.
As to performance, don’t worry about that until you know you have a problem.
SQL Server will create the clustered index on the Primary key column by default. If you use a wide key in the clustered index, all non-clustered indexes will also contain that wide key.