Question
So in my simple learning website, I use the built in ASP.NET authentication system.
I am adding now a user table to save stuff like his zip, DOB etc'. My question is:
- In the new table, should the key be the user name (the string) or the user ID which is that GUID looking number they use in the asp_ tables.
- If the best practice is to use that ugly guid, does anyone know how to get it? it seems to not be accessible as easily as the name (System.Web.HttpContext.Current.User.Identity.Name)
- If you suggest I use neither (not the guid nor the userName fields provided by ASP.NET authentication) then how do I do it with ASP.NET authentication? One option I like is to use the email address of the user as login, but how to I make ASP.NET authentication system use an email address instead of a user name? (or there is nothing to do there, it is just me deciding I "know" userName is actually an email address?
Please note:
- I am not asking on how get a GUID in .NET, I am just referring to the userID column in the asp_ tables as guid.
- The user name is unique in ASP.NET authentication
Answer
I would suggest using the username as the primary key in the table if the username is going to be unique, there are a few good reasons to do this:
- The primary key will be a clustered index and thus search for a users details via their username will be very quick.
- It will stop duplicate usernames from appearing
- You don't have to worry about using two different peices of information (username or guid)
- It will make writing code much easier because of not having to lookup two bits of information.
0 comments:
Post a Comment