Keys are used to make sure that no rows in a relation are repeated.

  1. A key is a group of one or more attributes that uniquely identify a row.
  2. A key functionally determines the other attributes in the row, thus it is always a determinant.
  3. Since relations cannot have duplicate rows, there is always one key (the composite of all attributes in the relation).
  4. Two or more attributes or attribute collections that can be a key are called candidate keys.
  5. Primary key: Whichever of the candidate keys is selected to be the key.
  6. Note that the term "key" in most DBMS products is an index.
Auto Manufacturers
Name Phone Address

In the table above, the attribute "Name" will work as a valid primary key, since no two auto manufacturers have the same name.

 

Students
Name Phone Address

In the "Students" table, however, we need both the "Name" attribute as well as the "Phone" attribute to uniquely identify the particular record (student) since more than one student could have the same name.  We assume that if there are two students with the same name, they will have different phone numbers.