|
|
 |
Re: FN-FORUM: [OT] flippancy - What's the best development platform for creating Web 2.0 business applications?
date posted 22nd November 2007 11:02
"Anthony Cartmell" [EMAIL REMOVED] wrote:
> an auto-incrementing integer ID seems quite logical. Allows any of the
> data for an "item" to change without it becoming a new item. Also makes
> for consistency, as all tables that need to be referred to have `id` as
> their primary key name.
>
> Isn't this what auto-incrementing fields are designed for?
No. They are just there to provide a possible key for any entity without a
candidate key; keys for idiots and very useful too. Most entities have no
suitable candidate keys (despite what they taught you at college). But when
a candiate key presents itself as clear as daylight - use that instead if it
can be conveniently indexed.
Suppose I had a link entity [which only exists to link two other entities in
an many-to-many relation]. It has only two data columns which are both
foreign keys to other entities. Why would I want to give it an autoincrement
key? The natural key is the existing pair of columns; no need to complicate
it further by adding another useless column.
|
 |
|