tags:

views:

386

answers:

2

When saving data in different sql tables, is it best to use the GUID userID or simply use the username? is there a performance difference when using guid?

+10  A: 

Use the guid. It is the system internal identifier for your users. This then allows the ability to change usernames if people wish.

This then fits nicely with the concept of an internal ID that means something to your system, versus the external ID that means something to your users.

Neil Barnwell
No only that, but user names can be changed and/or duplicated IRL.
Josef
It sure seems the correct way, but why isn't it accessible ...User.Identity.? I am trying to understand why it was done the way it was.
Brettski
+4  A: 

I saw a lot of discussions about performance in GUID vs. INT (auto increment). But I could recommend you use GUID.

Hm.. Are you asking about field used as primary or about using/not a relations (insert a GUID into a table having another table with GUID and user name associations) ?

abatishchev
primary in the Users table as guid. reference field in other tables (as guid or not)
zsharp
GUID vs Int is more regarding the clustered index of SQL Server. A monotonically increasing value (identity integer) is preferred for the Clustered index, regardless of the primary key.
Josef
@Josef: Now I understand why you are absolutely right :)
abatishchev