<s>
A	O
candidate	B-Application
key	I-Application
,	O
or	O
simply	O
a	O
key	O
,	O
of	O
a	O
relational	B-Application
database	I-Application
is	O
a	O
minimal	O
superkey	B-Application
.	O
</s>
<s>
In	O
other	O
words	O
,	O
it	O
is	O
any	O
set	O
of	O
columns	O
that	O
have	O
a	O
unique	O
combination	O
of	O
values	O
in	O
each	O
row	O
(	O
which	O
makes	O
it	O
a	O
superkey	B-Application
)	O
,	O
with	O
the	O
additional	O
constraint	O
that	O
removing	O
any	O
column	O
could	O
produce	O
duplicate	O
combinations	O
of	O
values	O
(	O
which	O
makes	O
it	O
a	O
minimal	O
superkey	B-Application
)	O
.	O
</s>
<s>
Because	O
a	O
candidate	B-Application
key	I-Application
is	O
a	O
superkey	B-Application
that	O
does	O
n't	O
contain	O
a	O
smaller	O
one	O
,	O
a	O
relation	O
can	O
have	O
multiple	O
candidate	B-Application
keys	I-Application
,	O
each	O
with	O
a	O
different	O
number	O
of	O
attributes	O
.	O
</s>
<s>
Specific	O
candidate	B-Application
keys	I-Application
are	O
sometimes	O
called	O
primary	B-Application
keys	I-Application
,	O
secondary	O
keys	O
or	O
alternate	B-Application
keys	I-Application
.	O
</s>
<s>
The	O
columns	O
in	O
a	O
candidate	B-Application
key	I-Application
are	O
called	O
prime	B-Application
attributes	I-Application
,	O
and	O
a	O
column	O
that	O
does	O
not	O
occur	O
in	O
any	O
candidate	B-Application
key	I-Application
is	O
called	O
a	O
non-prime	B-Application
attribute	I-Application
.	O
</s>
<s>
Every	O
relation	O
without	O
NULL	O
values	O
will	O
have	O
at	O
least	O
one	O
candidate	B-Application
key	I-Application
:	O
Since	O
there	O
cannot	O
be	O
duplicate	O
rows	O
,	O
the	O
set	O
of	O
all	O
columns	O
is	O
a	O
superkey	B-Application
,	O
and	O
if	O
that	O
is	O
n't	O
minimal	O
,	O
some	O
subset	O
of	O
that	O
will	O
be	O
minimal	O
.	O
</s>
<s>
There	O
is	O
a	O
functional	B-Application
dependency	I-Application
from	O
the	O
candidate	B-Application
key	I-Application
to	O
all	O
the	O
attributes	O
in	O
the	O
relation	O
.	O
</s>
<s>
The	O
superkeys	B-Application
of	O
a	O
relation	O
are	O
all	O
the	O
possible	O
ways	O
we	O
can	O
identify	O
a	O
row	O
.	O
</s>
<s>
The	O
candidate	B-Application
keys	I-Application
are	O
the	O
minimal	O
subsets	O
of	O
each	O
superkey	B-Application
and	O
as	O
such	O
,	O
they	O
are	O
an	O
important	O
concept	O
for	O
the	O
design	O
of	O
database	B-Application
schema	I-Application
.	O
</s>
<s>
The	O
definition	O
of	O
candidate	B-Application
keys	I-Application
can	O
be	O
illustrated	O
with	O
the	O
following	O
(	O
abstract	O
)	O
example	O
.	O
</s>
<s>
Consider	O
a	O
relation	B-Application
variable	I-Application
(	O
relvar	B-Application
)	O
R	O
with	O
attributes	O
(	O
A	O
,	O
B	O
,	O
C	O
,	O
D	O
)	O
that	O
has	O
only	O
the	O
following	O
two	O
legal	O
values	O
r1	O
and	O
r2	O
:	O
</s>
<s>
Since	O
superkeys	B-Application
of	O
a	O
relvar	B-Application
are	O
those	O
sets	O
of	O
attributes	O
that	O
have	O
the	O
uniqueness	O
property	O
for	O
all	O
legal	O
values	O
of	O
that	O
relvar	B-Application
and	O
because	O
we	O
assume	O
that	O
r1	O
and	O
r2	O
are	O
all	O
the	O
legal	O
values	O
that	O
R	O
can	O
take	O
,	O
we	O
can	O
determine	O
the	O
set	O
of	O
superkeys	B-Application
of	O
R	O
by	O
taking	O
the	O
intersection	O
of	O
the	O
two	O
lists	O
:	O
</s>
<s>
These	O
are	O
indeed	O
the	O
candidate	B-Application
keys	I-Application
of	O
relvar	B-Application
R	O
.	O
</s>
<s>
We	O
have	O
to	O
consider	O
all	O
the	O
relations	O
that	O
might	O
be	O
assigned	O
to	O
a	O
relvar	B-Application
to	O
determine	O
whether	O
a	O
certain	O
set	O
of	O
attributes	O
is	O
a	O
candidate	B-Application
key	I-Application
.	O
</s>
<s>
For	O
example	O
,	O
if	O
we	O
had	O
considered	O
only	O
r1	O
then	O
we	O
would	O
have	O
concluded	O
that	O
 { A , B } 	O
is	O
a	O
candidate	B-Application
key	I-Application
,	O
which	O
is	O
incorrect	O
.	O
</s>
<s>
However	O
,	O
we	O
might	O
be	O
able	O
to	O
conclude	O
from	O
such	O
a	O
relation	O
that	O
a	O
certain	O
set	O
is	O
not	O
a	O
candidate	B-Application
key	I-Application
,	O
because	O
that	O
set	O
does	O
not	O
have	O
the	O
uniqueness	O
property	O
(	O
example	O
 { A , D } 	O
for	O
r1	O
)	O
.	O
</s>
<s>
Note	O
that	O
the	O
existence	O
of	O
a	O
proper	O
subset	O
of	O
a	O
set	O
that	O
has	O
the	O
uniqueness	O
property	O
cannot	O
in	O
general	O
be	O
used	O
as	O
evidence	O
that	O
the	O
superset	O
is	O
not	O
a	O
candidate	B-Application
key	I-Application
.	O
</s>
<s>
from	O
the	O
set	O
of	O
functional	B-Application
dependencies	I-Application
.	O
</s>
<s>
It	O
is	O
quite	O
simple	O
to	O
find	O
a	O
single	O
candidate	B-Application
key	I-Application
.	O
</s>
<s>
then	O
is	O
a	O
candidate	B-Application
key	I-Application
.	O
</s>
<s>
That	O
is	O
,	O
many	O
attribute	O
orders	O
will	O
lead	O
to	O
the	O
same	O
candidate	B-Application
key	I-Application
.	O
</s>
<s>
There	O
is	O
a	O
fundamental	O
difficulty	O
for	O
efficient	O
algorithms	O
for	O
candidate	B-Application
key	I-Application
computation	O
:	O
</s>
<s>
Certain	O
sets	O
of	O
functional	B-Application
dependencies	I-Application
lead	O
to	O
exponentially	O
many	O
candidate	B-Application
keys	I-Application
.	O
</s>
<s>
which	O
yields	O
candidate	B-Application
keys	I-Application
:	O
</s>
<s>
That	O
is	O
,	O
the	O
best	O
we	O
can	O
expect	O
is	O
an	O
algorithm	O
that	O
is	O
efficient	O
with	O
respect	O
to	O
the	O
number	O
of	O
candidate	B-Application
keys	I-Application
.	O
</s>
<s>
The	O
following	O
algorithm	O
actually	O
runs	O
in	O
polynomial	O
time	O
in	O
the	O
number	O
of	O
candidate	B-Application
keys	I-Application
and	O
functional	B-Application
dependencies	I-Application
:	O
</s>
<s>
and	O
a	O
functional	B-Application
dependency	I-Application
,	O
</s>
<s>
It	O
may	O
however	O
be	O
covered	O
by	O
other	O
already	O
known	O
candidate	B-Application
keys	I-Application
.	O
</s>
<s>
If	O
not	O
,	O
then	O
minimizing	O
the	O
new	O
key	O
yields	O
a	O
new	O
candidate	B-Application
key	I-Application
.	O
</s>
<s>
The	O
key	O
insight	O
is	O
that	O
all	O
candidate	B-Application
keys	I-Application
can	O
be	O
created	O
this	O
way	O
.	O
</s>
