Chapter 5
Chapter 5
The first step before applying the rules in relational data model is converting
the conceptual design to a form suitable for relational logical model, which is
in a form of tables.
Converting ER Diagram to Relational Tables
Three basic rules to convert ER into tables or relations:
Rule 1: Entity Names will automatically be table names
Rule 2: Mapping of attributes: attributes will be columns of the respective
tables.
Atomic or single-valued or derived or stored attributes will be
columns
Composite attributes: the parent attribute will be ignored and the
decomposed attributes (child attributes) will be columns of the
table.
Multi-valued attributes: will be mapped to a new table where the
primary key of the main table will be posted for cross referencing.
FNamee LNamee
M 1 M Works For 1
Tel D Name
Start Date
Leads
End Date
Participate
PB onus
M
M
Project
PFund
PID PName
After we have drawn the ER diagram, the next thing is to map the ER into
relational schema so as the rules of the relational data model can be tested
for each relational schema. The mapping can be done for the entities
followed by relationships based on the rule of mapping. the mapping has
been done as follows.
At the end of the mapping we will have the following relational schema
(tables) for the logical database design phase.
Department
DID DName DLoc MEID
Project
PID PName PFund
Telephone
EID Tel
Employee
EID FName LName Salary EDID
Emp_Partc_Project
EID PID
Emp_Lead_Project
EID PID PBonus StartDa EndDat
te e
Normalization
A relational database is merely a collection of data, organized in a particular
manner. As the father of the relational database approach, Codd created a
series of rules (tests) called normal forms that help define that organization
1. Insertion Anomalies
2. Deletion Anomalies
3. Modification Anomalies
All the normalization rules will eventually remove the update anomalies that
may exist during data manipulation after the implementation. The update
anomalies are;
EmpI
D
FNam LNam SkillID Skill SkillType Scho SchoolA Skill
e e ol dd Level
12 Abebe Mekur 2 SQL Database AAU Sidist_Kilo 5
ia
16 Lemm Alemu 5 C++ Programm Unity Gerji 6
a ing
28 Chane Kebed 2 SQL Database AAU Sidist_Kilo 10
e
25 Abera Taye 6 VB6 Programm Helico Piazza 8
ing
65 Almaz Belay 2 SQL Database Helico Piazza 9
24 Dereje Tamir 8 Orac Database Unity Gerji 5
u le
51 Selam Belay 4 Prol Programm Jimma Jimma 8
og ing City
94 Alem Kebed 3 Cisc Networkin AAU Sidist_Kilo 7
e o g
18 Girma Derej 1 IP Programm Jimma Jimma 4
e ing City
13 Yared Gizaw 7 Java Programm AAU Sidist_Kilo 6
ing
Deletion Anomalies:
If employee with ID 16 is deleted then ever information about skill C+
+ and the type of skill is deleted from the database. Then we will not
have any information about C++ and its skill type.
Insertion Anomalies:
What if we have a new employee with a skill called Pascal? We can
not decide weather Pascal is allowed as a value for skill and we have
no clue about the type of skill that Pascal should be categorized as.
Modification Anomalies:
What if the address for Helico is changed from Piazza to Mexico? We
need to look for every occurrence of Helico and change the value of
School_Add from Piazza to Mexico, which is prone to error.
Data Dependency
The logical associations between data items that point the database designer
in the direction of a good database design are refered to as determinant or
dependent relationships.
X Y holds if whenever two tuples have the same value for X, they
must have the same value for Y
FDs are derived from the real-world constraints on the attributes and they
are properties on the database intension not extension.
Example
Dinner Type of
Course Wine
Meat Red
Fish White
Cheese Rose
Since the type of Wine served depends on the type of Dinner, we say Wine
is functionally dependent on Dinner.
Dinner Wine
Since both Wine type and Fork type are determined by the Dinner type, we
say Wine is functionally dependent on Dinner and Fork is functionally
dependent on Dinner.
Dinner Wine
Dinner Fork
Partial Dependency
If an attribute which is not a member of the primary key is dependent on
some part of the primary key (if we have composite primary key) then that
attribute is partially functionally dependent on the primary key.
Transitive Dependency
In mathematics and logic, a transitive relationship is a relationship of the
following form: "If A implies B, and if also B implies C, then A implies C."
Example:
If Mr X is a Human, and if every Human is an Animal, then Mr X must be an
Animal.
A normal form below represents a stronger condition than the previous one
Un Normalized Form(UNF):
Identify all data elements
First Normal Form(1NF):
Find the key with which you can find all data i.e. remove any repeating group
Second Normal Form(2NF):
Remove part-key dependencies (partial dependency). Make all data dependent on the
whole key.
Third Normal Form(3NF)
Remove non-key dependencies (transitive dependencies). Make all data dependent on
nothing but the key.
For most practical purposes, databases are considered normalized if they
adhere to the third normal form (there is no transitive dependency).