Re: Primary Keys (to autonumber or not ?)
From: Jeff Boyce (JeffBoyce_IF_at_msn.com-DISCARD_HYPHEN_TO_END)
Date: 01/19/05
- Next message: Jeff Boyce: "Re: Custom Validation Rules"
- Previous message: Nikos Yannacopoulos: "Re: Autonumber Lookup"
- In reply to: TonyB: "Primary Keys (to autonumber or not ?)"
- Next in thread: Lynn Trapp: "Re: Primary Keys (to autonumber or not ?)"
- Reply: Lynn Trapp: "Re: Primary Keys (to autonumber or not ?)"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 19 Jan 2005 05:30:15 -0800
Tony
I agree with everything Lynn mentioned.
I fall into the "tends to use Autonumber" camp (but that is only a
tendency). In dbs with multiple related tables, I've found it more
efficient (read "lazy") to use autonumber primary keys to save effort in
relating the tables. This lets me get on to more interesting issues, like
user interface, without spending extra time/effort discovering candidate
keys and selecting the one I'll use. And Lynn's discussion of "duplicates"
is right on point!
But I also use a "natural" primary key when it serves no purpose to include
an artificial (autonumber) key.
Best of luck!
Jeff Boyce
<Access MVP>
"TonyB" <tonyb@kerrisway.freeserve.co.uk> wrote in message
news:OhBZJPi$EHA.3700@tk2msftngp13.phx.gbl...
> I am trying to do something fairly simple in a access db. I have a table
> that contains a record for every sale made. Each sale needs to have an
> unique number of the form yyyy-mm-dd-xx (where xx starts from 01 each day)
> allocated when a new sale is entered, along with other info in other
fields.
> This is the number used to lookup any particular sale.
> So I could create a PK for the record which uses this field directly as
the
> key, which means not using an autonumber field.
> Or I could use a combined key using an autonumber field plus a date field
to
> lookup records when required in a report or query, and convert the
> auotnumber field plus date to the yyyy-mm-dd-xx form for reports, queries
> etc.
> I do want to search for records that have a particular value for
> yyyy-mm-dd-xx, or all records for a particular day etc so I felt it makes
> sense to create this field directly and use it as a natural key for the
> table. But it also could be done using an autonumber field and date
fields.
> However when "googling" this topic there do seem to be strong
contradictory
> opinions as to whether you should use autonumber fields always in Access,
or
> always use a natural key if possible. What are the pros and cons in this
> situation ?
>
> Regards
> Tony
>
>
- Next message: Jeff Boyce: "Re: Custom Validation Rules"
- Previous message: Nikos Yannacopoulos: "Re: Autonumber Lookup"
- In reply to: TonyB: "Primary Keys (to autonumber or not ?)"
- Next in thread: Lynn Trapp: "Re: Primary Keys (to autonumber or not ?)"
- Reply: Lynn Trapp: "Re: Primary Keys (to autonumber or not ?)"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|