At EasyTechJunkie, we're committed to delivering accurate, trustworthy information. Our expert-authored content is rigorously fact-checked and sourced from credible authorities. Discover how we uphold the highest standards in providing you with reliable knowledge.

Learn more...

What Is a Key Field?

T.S. Adams
T.S. Adams

A key field is either a column or a combination of columns in a database that uniquely identifies the specific entry in question. These fields are used to identify and enforce integrity across multiple tables in a database. These fields come in two general flavors: simple and compound keys, depending on the number of columns marked as the key field. When utilized in its original table, this field is known as a "primary" key; when utilized in another table as a method of linking the tables together, it is known as a "foreign" key.

To be useful as a key field, a key candidate must be unique, unalterable, and required. Uniqueness is simple to understand; it means that no other entry in the database can have a matching key value as any other entry. Unalterable means the information in the key value is fixed and immutable, that it will never change over time. Required means that for no entry in the database can the key value be left blank. For example, an optional category like race or nationality could not be used as a key field in an employees database because some employees might not be willing to provide this information.

Woman doing a handstand with a computer
Woman doing a handstand with a computer

Choosing appropriate key fields enables the database to maintain its integrity while remaining coherent between tables. For example, if a database lists employee records, a typical entry might contain an employee's first name, last name, date of birth, and social security or employee ID number. The obvious choice for a key field is either the social security or employee ID number; both of these would satisfy the requirements of unique, unalterable, and required. When attempting to search for a specific employee's record in the database, entering the number would immediately return no more than a single employee record. If using the employee's last name as the key field, it is possible that multiple employee records would be found, as more than one employee can share a last name.

One way to reduce the chances of accidentally choosing a key field that has the possibility of returning multiple records is to use a compound key. As opposed to a simple key, which uses only one column, a compound key uses an combination of multiple columns to represent the key fields. For example, using as a key a combination of the first name, last name, and date of birth of an employee would drastically reduce — but not wholly eliminate — the chances of violating the uniqueness requirement. This provides a solution when a good simple key is not readily available.

Discussion Comments


You'd be surprised how much money database administrators earn. Creating and maintaining databases is actually a very lucrative profession.

Post your comments
Forgot password?
    • Woman doing a handstand with a computer
      Woman doing a handstand with a computer