Database Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesDatabase Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old June 12th, 2004, 06:21 PM
EiSa EiSa is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: Norway
Posts: 184 EiSa User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 22 m 24 sec
Reputation Power: 6
The great primary-key debate

http://builder.com.com/5100-6388-1045050.html

I'm just wondering what your opinions are?

Reply With Quote
  #2  
Old June 12th, 2004, 07:20 PM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 6 m 11 sec
Reputation Power: 8
Send a message via ICQ to stumpy Send a message via MSN to stumpy
Meaningless values all the way - I think using a "natural key" will get you into trouble should your DB dramatically increase in size.
__________________
DevArticles Moderator
BlueSix - Web Development and Consulting

Reply With Quote
  #3  
Old June 13th, 2004, 02:17 AM
EiSa EiSa is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: Norway
Posts: 184 EiSa User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 22 m 24 sec
Reputation Power: 6
I prefer surrogate DB generated primary keys, but I will be happy for more arguments for both views. This because I in the near future will have to defend my choice of using surrogated primary keys in a article in information management I wrote at school. (I'm studying marketing management on my "old days", not IT).

In this article I recommended using surrogate primary keys when creating a fictive solution for an insurance company, and I know the teacher doesn't agree (he doesn't do programming and build databases himself, but is using the book written especially for this education as the "truth"). Since there are many things in this book that is totally wrong, I just had to go against the book on this area also. :-)

Reply With Quote
  #4  
Old June 13th, 2004, 08:36 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 6 m 11 sec
Reputation Power: 8
Send a message via ICQ to stumpy Send a message via MSN to stumpy
What do you mean by surrogate PK's?

(PS - Good topic)

Reply With Quote
  #5  
Old June 13th, 2004, 08:57 AM
EiSa EiSa is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: Norway
Posts: 184 EiSa User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 22 m 24 sec
Reputation Power: 6
Surrogate PK's is explained at page two in the article:
http://builder.com.com/5100-6388_14-1045050-2.html

Reply With Quote
  #6  
Old June 13th, 2004, 08:22 PM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 6 m 11 sec
Reputation Power: 8
Send a message via ICQ to stumpy Send a message via MSN to stumpy
Ahh - auto-incrementing id's - yup - I was always taught to use them (never heard the term "surrogate key" before though) and hadn't even considered using anything else. Like the article mentions - if for some reason your business rules change, you could definately be up the creek if you were using a natural key.

Reply With Quote
  #7  
Old June 20th, 2004, 05:35 AM
Beeblebrox Beeblebrox is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 1 Beeblebrox User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Against surrogate keys

The problem found with meaningless keys results in a database where all records are added to the end of it. This reduces efficiency when accessing sets.

A lot of database software, can organise data into the database by primary key so that adjacent primary keys are adjacent in the database. Using surrogate keys prevents this from happening,.

It is even worse for some DBMS, where they use chained blocks (always inserted at the end of the database) to allow for record expansion (use of VARCHAR). This means that to read a row, it may have to do a full seek from the beginning to the end of the database to get the first record. The second record would have a similar problem as that would have been inserted at the end, because of the surrogate key.

(I know that only two records is a bad example and that there woudl be no beginning and end, but if you consider it is the first row of a result set and the second row of a result set, then the description makes more sense).

I know of one system where surrogate keys are used exensively and it uses 3 IBM z/Servers to manage a subset of a billing system. and has 5 times the operating costs of similar (legacy) systems which dont use surrogate keys.

Normalisation is fundamental to RDBMS performance, it is how the software and the entire DBMS has been designed. If you violate normalisation rules you will suffer from severe performance problems once the database begins to reach any sort of size.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesDatabase Development > The great primary-key debate


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway