Re: serial numbers in tables
- From: Hans Besjes <besjes@xxxxxxx>
- Date: Fri, 20 Feb 2009 00:58:28 +0100
On 02/19/2009 23:25:42 Chris Brown <cbrown@xxxxxxxxxxxxxxxxxxxxxxxx> wrote:
Thank you, both. I think this "key field" idea is the one I am looking
for. I will explore this further. Thank you for getting me started!!
"Grip" <grip@xxxxxxxxxxxxx> wrote in message
news:194de389-1020-4df8-b3fc-1004f3a4bbcf@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Feb 19, 1:23 pm, "lariveesl" <larivees...@xxxxxxxxxxxxx> wrote:
I am making this up, just to use as an example.
If I were going to set up an employee db, I might want to have the data
for each person in several tables. One table could be contact info and
it would get an auto generated serial number for each employee entry.
If I now want to make another table with job details, what do I do for
the serial number? I would assume the serial numbers would have to be
the same for both tables.
Or is this a waste of time? Should I simply take ALL the info for each
employee and put it in one large table?
You would make a table for Employees that has an auto-entered serial
number. You would have a second table for Contact Info, that would have
two fields. One would be an auto enter serial number and the other would
be for the Employee serial number. These are called key fields. Key
fields that contain unique serial numbers to the table are called
"Primary Keys." Key fields that contain the numbers of other tables are
called "Foreign keys."
The simplest way to ensure that the Contact Info has the correct Employee
key field is to relate Contact Info to Employee by the Employee key
field. In the relationship, check Allow creation of related records...
Create a layout based on the Employee table occurance and put a portal
showing records from the Contact Info table.
When you enter a new phone number into the portal, a record with the
correct Employee key will be created in the Contact Info table.
G
Primary Key
A primary key field MUST be defined with certain characteristics: unique
serial not null (not empty) unique immutable (uncheck allow user override,
check prohibit modification of value during data entry)
EVERY table MUST have a primary key.
If the table is only "secondary", containing information linked to a main table by that main table's primary key, there is no need for a primary key...
The PK field can be either a number or text type; if defined as a number
field then an auto enter serial starting 1, increment 1 is used.
Why not use anumeric key field, and start numbering not at 1 but at 100001...
No problems with uniqueness, or strange sorting differences between text and numeric sorting.
If
defined as text, then an alpha-numeric value can be defined, e.g.
starting value EM000001, increment 1. Be aware number and text fields
have different sort characteristics, so if a pure number series is defined
for the auto increment type, and the field has been defined as a text
field, then sorting will look like: 1 10 100 11
A text field PK defined as an alphanumeric series, will sort as expected
EM00001 Em00002 EM00003
Wiki is as good a place as any to start with info about keys.
Hans Besjes
.
- Follow-Ups:
- Re: serial numbers in tables
- From: Lynn Allen
- Re: serial numbers in tables
- References:
- serial numbers in tables
- From: lariveesl
- Re: serial numbers in tables
- From: Grip
- Re: serial numbers in tables
- From: lariveesl
- Re: serial numbers in tables
- From: Chris Brown
- serial numbers in tables
- Prev by Date: Re: serial numbers in tables
- Next by Date: Re: serial numbers in tables
- Previous by thread: Re: serial numbers in tables
- Next by thread: Re: serial numbers in tables
- Index(es):
Relevant Pages
|
Loading