Joe Celko's Data and Databases: Concepts in Practice
By Joe Celko
Chapter 17: Keys
Chapter 17: Keys
Overview
A key is a combination of one or more columns in a table that uniquely identify each row of the table. In a relational database, you cannot access the data by its physical location, so you need a logical description of it for the engine to find it. There are four desirable properties of any key:
1.
Familiarity: Key values should be meaningful to users.
2.
Stability: Key values should not be volatile.
3.
Minimality: Columns should be included in a key only if they are necessary for uniqueness.
4.
Simplicity: Short, simple keys are preferable over long, conceptually complex keys.
These criteria may conflict in certain circumstances, and you may have to make trade-offs. For example, the longitude and latitude of a building are very stable, minimal, and simple in structure, but they are not familiar to most postal carriers; therefore, we will use the street address to locate the building when we address mail. However, the longitude and latitude of the building can be important in a database of deeds and titles.
Implementations of keys will vary from product to product, but they usually involve an index or other access method that includes an operation for assuring uniqueness. You might want to look at Chapter 5 for details.
17.1 Types of Keys
Here is a simple list of terminology that we will use for the rest of the chapter:
?
Primary key: A...
Copyright Morgan Kauffmann Publishers 1999 under license agreement with Books24x7