Professional Documents
Culture Documents
Alternatively we look at the requirements (for the application) and design the
relations directly without going through an intermediate stage.
Whichever approach is used, it is common to have room for improvement on the
initial schema.
The theory begins with stating the constraints that apply to the relation.
The most common constraint is 'the functional dependency' , which generalises the
idea of a key for a relation, .
Then we see how the theory gives us tools to improve our relations by
"decomposition of relations" - the replacement of one relation by two or more,
whose set of attributes == the set of attributes of the original undecomposed
relation
Notation: A1 ... A_N functionally determine B1, ... B_m == A1, ... A_n -> B1, ...,
B_m
this is equivalent to
holds.
the FD
title, year -> starName does not hold (counter example: the first two tuples
have the same title and year name but starName is different).
the FD holds for *all* instances of the relation, not a particular instance.
We say that attributes {A1, A2, ... , An} are a *key* for a relation if
(1) these attributes functionally determine all other attributes of the
relation. i.e. there are not two tuples in any R instance s.t they agree on
attributes A1 thru An
(2) no proper *subset* of {A1,....,An} functionally determines all other
attributes of R. Iow a key must be minimal.
Consider
{title, starName} is not a key because there could be two versions of a movie
(Spiderman!) made in two different years, with a star in common.
3.1.3 Superkeys
A set of attributes that contains a key, iow, the superset of attributes that form
a key, is a superkey.
Thus every key is a superkey. However, some superkeys are not (minimal and so not)
keys. A superkey determines all the other attributes of the relation, but it need
not satisfy the 2nd condition -minimality.
Terminology: Other books use 'key' to mean what we call 'superkey' - i.e a *not
necessarily * minimal collection of attributes that determine the rest of the
attributes of the relation
In this section, how to reason about FDs. i.e suppose we are told of a set of FDs
that a relation satisfies, we can then deduce what other FDs that relation
satisfies. This ability to deduce other 'satisfied FDs' is essential.
A motivating example: if we are told that the relation R (A, B, C) satisfies the
FDs A -> B, B->C
we can deduce that R satisfies the FDs A -> C .
"Proof":
Let (a1, b1, c1) and (a1, b2, c2) be two tuples of R.
Since the FD A -> B holds, and since the two tuples have the value a1 for the
attribute A, b1 must = b2.
And since FD B -> C holds, c1 must equal c2.
In this section, some rules about FDs. In general these allow us to replace one set
of FDs with another, or add to one set of FDs, more FDs that follow from the
original. e.g by the transitivity proved earlier, if given A -> B, and B -> C we
can add A -> C.
with
2. We can replace
with a single FD
e.g
title, year -> title
title -> title
We can assume any trivial FD, without having to justify it in terms of what other
FDs are asserted on the relation.