are here: Freetutes.com
Analysis and Design
Different Types of Keys in Relational Database Model
Now we’ll take up another feature of relational tables. That is different
type of keys. There are different types of keys, namely Primary keys, alternate
keys, etc. The different types of keys are described below.
Within a given relation, there can be one attribute with values that are unique
within the relation that can be used to identify the tuples of that relation.
That attribute is said to be primary key for that relation.
Composite primary key
Not every relation will have single-attribute primary key. There can be a possibility
that some combination of attribute when taken together have the unique identification
property. These attributes as a group is called composite primary key. A combination
consisting of a single attribute is a special case.
Existence of such a combination is guaranteed by the fact that a relation is
a set. Since sets don’t contain duplicate elements, each tuple of a relation
is unique with respect to that relation. Hence, at least the combination of all
attributes has the unique identification property.
In practice it is not usually necessary to involve all the attributes-some
lesser combination is normally sufficient. Thus, every relation does have a primary
(possibly composite) key.
Tuples represent entities in the real world. Primary key serves as a unique
identifier for those entities.
In a relation, there can be more than one attribute combination possessing
the unique identification property. These combinations, which can act as primary
key, are called candidate keys.
Fig. 8.6 Table having “EmpNo” and “SocSecurityNo”
as candidate keys
A candidate key that is not a primary key is called an alternate key. In fig.
8.6 if EmpNo is primary key then SocSecurityNo is the alternate key.
Previous Page | Contents
| Next Page >>