Thomas said:
Need to combine two fields into one in a customer database table, for
example; first name field and last name field need to combine into a
new field called first/last name, for the purpose of creating a
primary key field to avoid duplicate records. Any help would be
greatly appreciated!
Thomas
In situations where you can't guarantee the uniqueness of any single field,
you may be able to designate two or more fields as the primary key. The most
common situation where this arises is in the table used to relate two other
tables in a many-to-many relationship. For example, an Order Details table
can relate the Orders and Products tables. Its primary key consists of two
fields: OrderID and ProductID. The Order Details table can list many
products and many orders, but each product can only be listed once per
order, so combining the OrderID and ProductID fields produces an appropriate
primary key.
Each product can be listed only once per order.
Another example would be an inventory database that uses a field part number
of two or more fields (part and subpart).
If you are in doubt about whether you can select an appropriate combination
of fields for a multiple-field primary key, you should probably add an
AutoNumber field and designate it as the primary key instead. For example,
combining FirstName and LastName fields to produce a primary key is not a
good choice, since you may eventually encounter duplication in the
combination of these two fields.
In a multiple-field primary key, field order may be important to you. The
fields in a multiple-field primary key are sorted according to their order
in table Design view. You can change the order of the primary key fields in
the Indexes window.
Note, First and last name may not be a great choice as you may have more
than one Tom Jones or you may have someone enter Tom Jones and next time
enter Thomas Jones.