T
TonyB
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
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