473,569 Members | 2,617 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 4533
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
13950
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
2142
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"...
13
31746
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...
22
2312
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...
6
3668
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...
2
2298
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...
0
1347
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: ...
13
3490
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
3175
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 ...
3
2012
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
7701
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8130
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...
1
7677
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...
0
7979
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...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3653
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...
0
3643
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2115
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
940
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...

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.