You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Stefan Wagner <wa...@ixtern.de> on 2001/08/21 12:29:40 UTC
Use of User_id
Hi!
I got a question regarding the user_id, because I was wondering why it exists
at all. The login_name is unique already, so why do you create a primary key
with the user_id? I don't see an advantage.
Thanks for your answers.
Ciao,
Stefan
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org
Re: Use of User_id
Posted by Scott Eade <se...@backstagetech.com.au>.
From: "Stefan Wagner" <wa...@ixtern.de>
> Hi!
>
> I got a question regarding the user_id, because I was wondering why it exists
> at all. The login_name is unique already, so why do you create a primary key
> with the user_id? I don't see an advantage.
>
> Thanks for your answers.
>
> Ciao,
> Stefan
What if you want to change your login_name? Having user_id insulates you
from having to change values in related tables.
Scott
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org
Re: Use of User_id
Posted by Jason van Zyl <jv...@apache.org>.
On 8/21/01 6:29 AM, "Stefan Wagner" <wa...@ixtern.de> wrote:
> Hi!
>
> I got a question regarding the user_id, because I was wondering why it exists
> at all. The login_name is unique already, so why do you create a primary key
> with the user_id? I don't see an advantage.
>
> Thanks for your answers.
The idea is called a surrogate key, and is explained by Scott Amber in his
papers which you can find at www.ambysoft.com. The unique identifier for an
object should never have any business/domain meaning. A little exerpt from
the Object Primer:
---
Giving your keys meaning is a fatal mistake. If your users decide to change
the business meaning, or if they want to add some digits or make a number
alphanumeric, you need to make changes to your database in every single spot
where you use that information. Anything used as a primary key in one table
is virtually guaranteed to be used in other tables as a foreign key. What
should be a simple change, adding a digit to your customer number, can be a
huge maintenance nightmare. Yuck. In the relational database world, keys
without business meaning are all surrogate keys.
---
He goes into further detail in the book, but the same arguments can be found
in the PDFs that are freely available from Scott Ambler's site.
> Ciao,
> Stefan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
--
jvz.
Jason van Zyl
http://tambora.zenplex.org
http://jakarta.apache.org/turbine
http://jakarta.apache.org/velocity
http://jakarta.apache.org/alexandria
http://jakarta.apache.org/commons
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org
Re: Use of User_id
Posted by Jon Stevens <jo...@latchkey.com>.
on 8/21/01 3:29 AM, "Stefan Wagner" <wa...@ixtern.de> wrote:
> Hi!
>
> I got a question regarding the user_id, because I was wondering why it exists
> at all. The login_name is unique already, so why do you create a primary key
> with the user_id? I don't see an advantage.
>
> Thanks for your answers.
>
> Ciao,
> Stefan
If you want to join across tables, joining by an integer id is more
efficient than joining with a string.
-jon
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org