Sheet5 solution-CC471-Fall 2021
Sheet5 solution-CC471-Fall 2021
Sheet # 5 Solution
Mapping and Normalization
1. The figure below shows an ER schema for a database that may be used to keep track of transport
ships and their locations for maritime authorities. Map this schema into a relational schema, and
specify all primary keys and foreign keys.
A minimal set of attributes whose closure includes all the attributes in R is a key.
(One can also apply algorithm 15.4a (see chapter 15 in the textbook)). Since the
closure of {A, B}, {A, B}+ = R, one key of R is {A, B} (in this case, it is the only
key).
To normalize R intuitively into 2NF then 3NF, we take the following steps
(alternatively, we can apply the algorithms discussed in Chapter 15):
First, identify partial dependencies that violate 2NF. These are attributes that are
functionally dependent on either parts of the key, {A} or {B}, alone. We can calculate
the closures {A}+ and {B}+ to determine partially dependent attributes:
{A}+ = {A, D, E, I, J}. Hence {A} -> {D, E, I, J} ({A} -> {A} is a trivial
dependency)
{B}+ = {B, F, G, H}, hence {A} -> {F, G, H} ({B} -> {B} is a trivial dependency)
To normalize into 2NF, we remove the attributes that are functionally dependent on
part of the key (A or B) from R and place them in separate relations R1 and R2, along
with the part of the key they depend on (A or B), which are copied into each of these
relations but also remains in the original relation, which we call R3 below:
R1 = {A, D, E, I, J}, R2 = {B, F, G, H}, R3 = {A, B, C}
The new keys for R1, R2, R3 are underlined. Next, we look for transitive
dependencies in R1, R2, R3. The relation R1 has the transitive dependency {A} ->
{D} -> {I, J}, so we remove the transitively dependent attributes {I, J} from R1 into a
relation R11 and copy the attribute D they are dependent on into R11. The remaining
Alex University - Faculty of Engineering Computer & Communications Program
Specialized Scientific Programs CC471, Database Systems
Fall 2021 Instructor: Dr. Yousry Taha
attributes are kept in a relation R12. Hence, R1 is decomposed into R11 and R12 as
follows:
R11 = {D, I, J}, R12 = {A, D, E}
The relation R2 is similarly decomposed into R21 and R22 based on the transitive
dependency {B} -> {F} -> {G, H}:
R2 = {F, G, H}, R2 = {B, F}
The final set of relations in 3NF are {R11, R12, R21, R22, R3}