On 8/21/01 6:29 AM, "Stefan Wagner" <[EMAIL PROTECTED]> 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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

-- 

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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to