Database Reference
In-Depth Information
 Name and Address are eligible. The combined values of both fields will give a unique
identifier for a given record.
 Branch is ineligible because it can contain duplicate as shown in figure.
 City is ineligible because it can contain duplicate values as shown in figure.
Student table has two candidate keys: Registration No. and the combination of Name and
Address field.
4.8.2 Primary Keys (PK)
A primary key is used to uniquely identify a record in a table. Unique identification for
each record is required because there is no other way to find a record without the possibil-
ity of finding more than one record, if the unique identifier is not used.
A primary key value uniquely identifies a given record within a table and represents that
record throughout the entire database. It also helps to protect against duplicate records. A
primary key must conform to the exact same elements as a candidate key. A primary key is
selected from a table's pool of available candidate keys. Identify each qualified candidate
key in the table, and select one of them to become the official primary key of the table. In
addition to being unique, a primary key cannot be null. There must be a value for the attrib-
ute every time. Another characteristic is that primary keys are indexed. This allows data to
be sorted and retrieved faster.
Here are a couple of guidelines to select an appropriate primary key:
 If there are a single-field candidate key and a composite candidate key, choose the single
field candidate key. Candidate key that contains the least number of fields is best suitable
primary key.
 Choose a candidate key that incorporates part of the table name within its own name. For
example, a candidate key with a name such as EmployeeID is a good choice for the Em-
ployee table.
Example 4:
In the above figure, Registration No. uniquely identifies a student. Therefore, it is
better to use Registration No as a primary key for student table.
Example 5:
Examine the candidate keys and choose one to serve as the primary key for the table. The
choice is largely arbitrary—you can choose the one that you believe most accurately iden-
Search WWH ::




Custom Search