What purpose does autonumber serve?

M

Mike Collard

I don't see the purpose of an autonumber field since a
record cannot be linked to another table with it because
the numbers wouldn't tally. I know I'm missing something
but I can't see what!
 
C

Craig Alexander Morrison

None. (vbg)

If you are to use an AutoNumber for Primary Key (instead of real data) you
should note that the related field in the related table (Foreign Key) needs
to be a Long Integer and not another AutoNumber.
 
N

Nikos Yannacopoulos

Mike,

An Autonumber is an easy way to add a PK to your table, when none of the
other fields is appropriate for the purpose, for whatever reason (and there
are quite a few).

HTH,
Nikos
 
C

Chris Nebinger

I think are are looking at it slighty wrong.

Consider the case of Teachers and Classes. One teacher
will teach several classes, but each class will be taught
by one teacher (in our example, assume this is true).

Your teacher table could look like:
TeacherID----AutoNumber
TeacherName--Text

Our Classes would look like:
ClassID------AutoNumber
ClassName----Text
TeacherID----Number, Long


TeacherID in each table would link to each other. So the
data would look like:

TeacherID------------TeacherName
1--------------------Mr. Smith
2--------------------Mrs. Jones
3--------------------Mrs. Miller


Classes
ClassID--------------ClassName----------TeacherID
1--------------------Algebra I----------1
2--------------------Algebra II---------1
3--------------------American History---2
4--------------------Western Civ--------2
5--------------------English 101--------3
6--------------------English 102--------3
7--------------------Geometery----------1


So what classes does each teacher teach?

Select TeacherName, ClassName from Teachers INNER JOIN
Classes on Teachers.TeacherID = Classes.TeacherID


Chris Nebinger
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top