What is a key field?

The key field is either a column or a combination of columns in a database that uniquely identifies a specific item. These fields are used to identify and enforce integrity across multiple tables in the database. The key fields are supplied in two general flavors: simple and folded keys, depending on the number of columns marked as the key field. When used in its original table, the key field is known as the "primary" key; If it is used in another table as a method of connecting tables together, it is known as a "foreign" key.

If you want to be useful as a key field, the key candidate must be unique, unchanging and desired. The uniqueness is easy to understand; This means no other item in the database can have a value corresponding to the key value like any other record. Unsurable means that the key value of the key value is fixed and unchanged, that it will never change over time. Required means that for any record in the database, the key value may be left toDno. For example, an optional category such as Race or Nationality could not be used as key fields in the employee database, because some employees may not be willing to provide this information.

Selecting the appropriate key fields allows the database to maintain its integrity while remaining coherent between tables. For example, if the database states employees' records, a typical record may contain first name, surname, date of birth and social security or employee number. The apparent option for a key field is either the social security number or the employee number; Both would meet the requirements of unique, unchanged and required. When trying to search for a particular employee in the database, the number would immediately return more than one employee's record. If you use an employee's surname as a key field, it is possible to find more employees' records as more thanOne employee can share a surname.

One way to reduce the chances of random selection of a key field that has the option to return more records is to use a folded key. Unlike a simple key that uses only one column, the compound key uses a combination of multiple columns to represent key fields. For example, use as a keys would reduce the combination of first name, surname and date of birth of an employee drastically - but not completely eliminated - the chances of violating the uniqueness requirement. This provides a solution when a simple key is not easy to access.

IN OTHER LANGUAGES

Was this article helpful? Thanks for the feedback Thanks for the feedback

How can we help? How can we help?