473,888 Members | 1,462 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using an auto-number as a primary key

At http://www.blueclaw-db.com/tips_tricks.htm I came across a section
which is included below and was hoping for some comment on the
article.

--------------

Almost never use this auto-number field as the primary key of the
table.

If you are thinking of hiring an Access programmer or consultant ask
to see a screen shot of a relationship diagram from an Access database
he/she has built. If you see an auto-number ID field in bold then ask
them 'what will prevent two records with the same data getting into
this table?' If they can't give you a good answer then don't hire
them.
----------------------------

Geoff
Nov 12 '05 #1
5 4559
DFS
Geoff,

I didn't read the whole article, but what you quoted is a simplistic
statement made by someone with no knowledge of database design. What will
prevent two records with the same data from being added to the table is a
unique index on whichever fields constitute uniqueness. This index is
unrelated to the autonumber primary key field.

Many, if not most, databases use an automatically generated integer value
for a primary key in some or most tables. I can't say they're appropriate
in every case, but if I see a database using only semantic keys (these are
primary keys set on fields with system data in them: last name, first name,
job title, etc) it's not hard to find tables where updating the data becomes
difficult because of the primary key structure.

Thinking about my systems, I use a combination of semantic and non-semantic
primary keys. It just depends: on the system, how many tables (if you have
to join 8 tables to get a query with meaningful data in it you may want to
stay away from non-semantic keys), how much data, etc.
Semantic key example:

CodeTable
CodeID

CategoryTable
CategoryID

AirCarriersTabl e
AirCarrierID

PassengersTable
PassengerID
PassengerName

TransactionTabl e
CodeID
CategoryID
AirCarrierID
PassengerID

In this case, you end up with a transaction table full of just ID numbers,
and you have to create a query joining all the tables to see meaningful
data.

Here's a discussion on primary keys
http://www.4square.net/papers/NonSemanticKeys.html in which the author
argues for ONLY an autonumber type (non-semantic) primary key.

"Geoff Cayzer" <ca****@optusne t.com.au> wrote in message
news:22******** *************** **@posting.goog le.com...
At http://www.blueclaw-db.com/tips_tricks.htm I came across a section
which is included below and was hoping for some comment on the
article.

--------------

Almost never use this auto-number field as the primary key of the
table.

If you are thinking of hiring an Access programmer or consultant ask
to see a screen shot of a relationship diagram from an Access database
he/she has built. If you see an auto-number ID field in bold then ask
them 'what will prevent two records with the same data getting into
this table?' If they can't give you a good answer then don't hire
them.
----------------------------

Geoff

Nov 12 '05 #2
"Geoff Cayzer" <ca****@optusne t.com.au> wrote in message
news:22******** *************** **@posting.goog le.com...
At http://www.blueclaw-db.com/tips_tricks.htm I came across a section
which is included below and was hoping for some comment on the
article.

--------------

Almost never use this auto-number field as the primary key of the
table.

If you are thinking of hiring an Access programmer or consultant ask
to see a screen shot of a relationship diagram from an Access database
he/she has built. If you see an auto-number ID field in bold then ask
them 'what will prevent two records with the same data getting into
this table?' If they can't give you a good answer then don't hire
them.
----------------------------

Geoff


Personally, I can't agree with that statement. An auto-number is often a
suitable primary key. The principal function of the primary key is not to
prevent data duplication, though it sometimes does this, but rather, unique
identification of every record in a table. Auto-number is an easy way to
generate unique values.
Nov 12 '05 #3
"DFS" <no******@nospa m.com> wrote in message
news:vt******** ****@corp.super news.com...
Geoff,

I didn't read the whole article, but what you quoted is a simplistic
statement made by someone with no knowledge of database design. What will
prevent two records with the same data from being added to the table is a
unique index on whichever fields constitute uniqueness. This index is
unrelated to the autonumber primary key field.
IMO, what you say is correct, however, concluding that the author of that
statement has "no knowledge of database design", based on a single small
error, is unfair. And probably not correct.
Many, if not most, databases use an automatically generated integer value
for a primary key in some or most tables. I can't say they're appropriate
in every case, but if I see a database using only semantic keys (these are
primary keys set on fields with system data in them: last name, first name, job title, etc) it's not hard to find tables where updating the data becomes difficult because of the primary key structure.

Thinking about my systems, I use a combination of semantic and non-semantic primary keys. It just depends: on the system, how many tables (if you have to join 8 tables to get a query with meaningful data in it you may want to
stay away from non-semantic keys), how much data, etc.
Semantic key example:

CodeTable
CodeID

CategoryTable
CategoryID

AirCarriersTabl e
AirCarrierID

PassengersTable
PassengerID
PassengerName

TransactionTabl e
CodeID
CategoryID
AirCarrierID
PassengerID

In this case, you end up with a transaction table full of just ID numbers,
and you have to create a query joining all the tables to see meaningful
data.

Here's a discussion on primary keys
http://www.4square.net/papers/NonSemanticKeys.html in which the author
argues for ONLY an autonumber type (non-semantic) primary key.

"Geoff Cayzer" <ca****@optusne t.com.au> wrote in message
news:22******** *************** **@posting.goog le.com...
At http://www.blueclaw-db.com/tips_tricks.htm I came across a section
which is included below and was hoping for some comment on the
article.

--------------

Almost never use this auto-number field as the primary key of the
table.

If you are thinking of hiring an Access programmer or consultant ask
to see a screen shot of a relationship diagram from an Access database
he/she has built. If you see an auto-number ID field in bold then ask
them 'what will prevent two records with the same data getting into
this table?' If they can't give you a good answer then don't hire
them.
----------------------------

Geoff


Nov 12 '05 #4
DFS
"Randy Harris" <ra***@SpamFree .com> wrote in message
news:yu******** **************@ newssvr28.news. prodigy.com...
"DFS" <no******@nospa m.com> wrote in message
news:vt******** ****@corp.super news.com...
Geoff,

I didn't read the whole article, but what you quoted is a simplistic
statement made by someone with no knowledge of database design. What will prevent two records with the same data from being added to the table is a unique index on whichever fields constitute uniqueness. This index is
unrelated to the autonumber primary key field.


IMO, what you say is correct, however, concluding that the author of that
statement has "no knowledge of database design", based on a single small
error, is unfair. And probably not correct.


True - maybe a little unfair and incorrect.

As I said, I didn't read the article from which that quote came, but it's
definitely not a small error. It's a huge error, which clearly demonstrates
LACK OF (previously I said NO) knowledge of database design. Perusing the
article http://www.blueclaw-db.com/tips_tricks.htm I see the author knows
more than I expected, but still makes some odd and incorrect statements,
such as

"Again, never use the Unique Numeric ID (auto-number) for the primary key
unless it is used as data in other areas of your business (examples would be
Serial_Number_I D, PO_Number_ID)."

I hope you're not the author, Randy.


Many, if not most, databases use an automatically generated integer value for a primary key in some or most tables. I can't say they're appropriate in every case, but if I see a database using only semantic keys (these are primary keys set on fields with system data in them: last name, first

name,
job title, etc) it's not hard to find tables where updating the data

becomes
difficult because of the primary key structure.

Thinking about my systems, I use a combination of semantic and

non-semantic
primary keys. It just depends: on the system, how many tables (if you

have
to join 8 tables to get a query with meaningful data in it you may want to stay away from non-semantic keys), how much data, etc.
Semantic key example:

CodeTable
CodeID

CategoryTable
CategoryID

AirCarriersTabl e
AirCarrierID

PassengersTable
PassengerID
PassengerName

TransactionTabl e
CodeID
CategoryID
AirCarrierID
PassengerID

In this case, you end up with a transaction table full of just ID numbers, and you have to create a query joining all the tables to see meaningful
data.

Here's a discussion on primary keys
http://www.4square.net/papers/NonSemanticKeys.html in which the author
argues for ONLY an autonumber type (non-semantic) primary key.

"Geoff Cayzer" <ca****@optusne t.com.au> wrote in message
news:22******** *************** **@posting.goog le.com...
At http://www.blueclaw-db.com/tips_tricks.htm I came across a section
which is included below and was hoping for some comment on the
article.

--------------

Almost never use this auto-number field as the primary key of the
table.

If you are thinking of hiring an Access programmer or consultant ask
to see a screen shot of a relationship diagram from an Access database
he/she has built. If you see an auto-number ID field in bold then ask
them 'what will prevent two records with the same data getting into
this table?' If they can't give you a good answer then don't hire
them.
----------------------------

Geoff



Nov 12 '05 #5

"DFS" <no******@nospa m.com> wrote in message
news:vt******** ****@corp.super news.com...
"Randy Harris" <ra***@SpamFree .com> wrote in message
news:yu******** **************@ newssvr28.news. prodigy.com...
"DFS" <no******@nospa m.com> wrote in message
news:vt******** ****@corp.super news.com...
Geoff,

I didn't read the whole article, but what you quoted is a simplistic
statement made by someone with no knowledge of database design. What will prevent two records with the same data from being added to the table
is
a unique index on whichever fields constitute uniqueness. This index is
unrelated to the autonumber primary key field.
IMO, what you say is correct, however, concluding that the author of that statement has "no knowledge of database design", based on a single small
error, is unfair. And probably not correct.


True - maybe a little unfair and incorrect.

As I said, I didn't read the article from which that quote came, but it's
definitely not a small error. It's a huge error, which clearly

demonstrates LACK OF (previously I said NO) knowledge of database design. Perusing the
article http://www.blueclaw-db.com/tips_tricks.htm I see the author knows
more than I expected, but still makes some odd and incorrect statements,
such as

"Again, never use the Unique Numeric ID (auto-number) for the primary key
unless it is used as data in other areas of your business (examples would be Serial_Number_I D, PO_Number_ID)."

I hope you're not the author, Randy.


No, definitely not. I make no claims to being an expert. I agree as well,
however, that second statement above is also poor advice. Perhaps a more
serious error than the earlier one. I believe that auto-number keys should
never, under any circumstances, be used to contain data. So called "smart
keys" are very poor design.
Nov 12 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
13965
by: Glabbeek | last post by:
I'm changing the layout of my site. Instead of using tables, I will use DIVs. It's working fine, except for 1 thing: In IE6 some DIVs are not the correct width. Mozilla and Opera are showing the page the way I want. Does anybody know a solution for this? First of all, the code I am using: CSS ------- body {
0
2158
by: Matt Kruse | last post by:
I'm making changes to an intranet web app that uses only IE6 as the browser. It makes use of CSS expressions for dynamic positioning and other tricks, and it works quite well. My question is: Why can't I get expressions to work as values in a clip definition? This works fine to hide the top half of the table: <table border="1" style="position:absolute;clip:rect(50%,auto,auto,auto);">
13
31780
by: Mike | last post by:
We are using: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> Using CSS (not html since align=center and <center> are deprecated) I can get it to work in IE6 (but not NS 7 or Firefox) with. <div style="text-align:center; display:block; "><img src="myimg.gif"
22
2375
by: Bradley | last post by:
Has anyone else noticed this problem? I converted the back-end to A2000 and the performance problem was fixed. We supply a 97 and 2000 version of our software so we kept the backend in A97 to make upgrading simple for users. We've done it like that for years but a new client has been having severe performance issues... solved by converting the backend to 2000. -- regards, Bradley
6
3701
by: windandwaves | last post by:
Hi Folk Some of my clients asked me to create "fancy emails" for them (aka html formatted emails). I know how to make a nice html document, but I had trouble creating a simple way to provide the document to my clients so that they could use it to. I know most of them use Outlook XP or Outlook 2003, so what I created was a page that creates a Visual Basic script that, when saved to the desktop and
2
2305
by: abhishek11 | last post by:
Hi All I have a box with shadow around it. Now i have to render a red bar inside it at the top. This red bar should expand when the box expands but this is not happening in mozilla. Here is the code which I am using-- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <style type="text/css">
0
1358
by: rgebbie | last post by:
I have seen some previous posts regarding problems building Perl on AIX with gcc. Unfortunately, none of the posts produced any answers to the problem. I am also having similar problems, and I hope there are answers for them. I am able to run Configure, and do the 'make' successfully, but doing 'make test' produces numerous failures, like: # Can't load '../lib/auto/File/Glob/Glob.so' for module File::Glob: dlopen: ../l...
13
3537
by: Javad | last post by:
Hello I know that I should get the information of windows internet connections by using "rasapi32.dll" library, and I also have some sample codes, but I can't make them work. My exact need is to get the "UserName" of a connection. How is it possible? plz hlp thnk u
10
3208
by: =?Utf-8?B?TWF0dA==?= | last post by:
I am using the following code to connect to and download files from an ftp server, but the Symantec anti-virus software on some of my customers machines tells them that their computers are attacking the Ftp server with "FTP Pathname Glob BO". See the following link for more info: http://www.symantec.com/avcenter/attack_sigs/s20430.html This is standard .Net code, so I'm not understanding why it would trigger such a response. Also,...
3
2026
by: gudiya | last post by:
hi, My code works but i am missing the first 2 characters of file name. Any idea why???? using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing;
0
9800
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11181
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10778
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10886
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10439
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9597
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5819
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
4245
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3252
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.