RE: [Phplib-users] user_id versus username in auth_user schema
Brought to you by:
nhruby,
richardarcher
|
From: Layne W. <la...@if...> - 2002-05-25 00:06:50
|
> Why is there both a user_id and username column in the > auth-user table? The > username is declared unique, so why not just make it the > primary key and get rid of > the user_id column? I'm not the original developer, so I can't tell you why that design decision was made, but I will tell you why I like it the way it is. Although the username is unique, it does not necessarily have to be static throughout its lifetime. Many people who use PHPLib use email addresses as the username. Without a separate user_id, any related tables will need to be updated when a user wants to update their email address - some of those tables may have been archived into read-only formats rendering an update impossible. Another scenario would be a user registering under an offensive username. With a separate user_id, I have the flexibility of changing the username or deleting the account, whichever suits my tastes. Remember, PHPLib is a very generalized library that allows developers to use it however they like. If you want to reference other data using the username instead of the user_id, go ahead, no one is telling you not to. Layne Weathers Ifworld Inc. |