In the ApplicationServices database, so kindly created for me by the aspnet_regsql tool, there is a table dbo.aspnet_Users, which keeps all the user-related info.
So, when creating my dbo.Note table, I will store, together with all the note-related info, some user identity, to be able to distinguish which note actually belongs to the current user.
The question is: What should I use - UserId or UserName?
Both are unique, UserId by virtue of being a GUID (and also, a primary key), and UserName by virtue of the unique clustered index (technically, it is unique within the application).
So, pro and contra:
Pro:
- The UserName, being used in every query, will be the perfect candidate for the clustered index, which will guarantee the user-related records are fetched very quickly.
- I am going to have a serious problem once I decide it is possible for two users to have the same user name. Somehow I really doubt it.
- I might have a problem if I decide I would like to re-use user names, and I don't properly remove the user data left from the previous owner.

No comments:
Post a Comment