0% found this document useful (0 votes)
77 views

Sheet5 solution-CC471-Fall 2021

1) The document describes mapping an ER schema for a database that tracks ship locations into a relational schema. It specifies primary keys and foreign keys for the relations. 2) It then analyzes a relation with attributes ABC and tuples to determine which dependencies do not hold. 3) Finally, it takes a universal relation R with attributes and functional dependencies and decomposes it into 3NF through identifying partial dependencies, then removing them and transitively dependent attributes into separate relations. The key for R is identified as {A,B}.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
77 views

Sheet5 solution-CC471-Fall 2021

1) The document describes mapping an ER schema for a database that tracks ship locations into a relational schema. It specifies primary keys and foreign keys for the relations. 2) It then analyzes a relation with attributes ABC and tuples to determine which dependencies do not hold. 3) Finally, it takes a universal relation R with attributes and functional dependencies and decomposes it into 3NF through identifying partial dependencies, then removing them and transitively dependent attributes into separate relations. The key for R is identified as {A,B}.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Alex University - Faculty of Engineering Computer & Communications Program

Specialized Scientific Programs CC471, Database Systems


Fall 2021 Instructor: Dr. Yousry Taha

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.

Primary keys are underlined, Foreign Keys are in italics.


COUNTRY(Name, Continent)
SEA(Name)
PORT(Country_Name, Pname, Sea_Name)
SHIP_TYPE(Type, Tonnage, Hull)
SHIP(Sname, Owner, Country_Name, Pname, Type)
Alex University - Faculty of Engineering Computer & Communications Program
Specialized Scientific Programs CC471, Database Systems
Fall 2021 Instructor: Dr. Yousry Taha

SHIP_MOVEMENT(Sname, Date, Time, Longitude, Latitude)


PORT_VISIT(Sname, Country_Name, Pname, Start_date, End_date)
2. Suppose that we have the following three tuples in a legal instance of a relation schema S with
three attributes ABC (listed in order): (1,2,3), (4,2,3), and (5,3,3).
1) Which of the following dependencies can you infer does not hold over schema S?
(a) A → B, (b) BC → A, (c) B→ C
2) Can you identify any dependencies that hold over S?

3. Consider the universal relation R = {A, B, C, D, E, F, G, H, I, J} and the set of functional


dependencies F={{A, B} →{C}, {A}→{D, E}, {B}→{F}, {F}→{G, H}, {D]→{I, J}}. What is the key for R?
Decompose R into 2NF and then 3NF relations.

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}

You might also like