| You
are here: Freetutes.com
> Systems
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.
Primary key
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.
Candidate key
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.
| EmpNo |
SocSecurityNo |
Name |
Age |
| 1011 |
2364236 |
Harry |
21 |
| 1012 |
1002365 |
Sympson |
19 |
| 1013 |
1056300 |
Larry |
24 |
Fig. 8.6 Table having “EmpNo” and “SocSecurityNo”
as candidate keys
Alternate key
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.
See Also
<<
Previous Page | Contents
| Next Page >>
|