Chapter 4 - Logical Database Design
Chapter 4 - Logical Database Design
Chapter: four
Logical Database Design
Outlines
Logical Database Design
Normalization
Functional Dependencies
Steps of Normalization
2
Logical Database Design
The process of constructing a model of the information
used in an enterprise based on a specific data model
Converting ER Diagram to Relational Tables
Three basic rules to convert ER into tables or
relations:
For a relationship with One-to-One Cardinality
All the attributes are merged into a single table.
3
Cont.…
For a relationship with One-to-Many Cardinality:
– Post the primary key or candidate key from the
“one” side as a foreign key attribute to the “many”
side.
6
Cont.…
Example of problems related with Anomalies
Deletion Anomalies: If employee with ID 16 is deleted
– 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?
– Pascal should be categorized as what??
Modification Anomalies: What if the address for Helico is changed from Piazza
to Mexico? Modify in all locations
– prone to errors
7
Functional Dependencies
We say an attribute B has a functional dependency on
another attribute A if for any two records, which have the
same value for A, then the values for B in these two records
must be the same.
We illustrate this as:
AB
B is functionally dependent on A.
A determines B, or B is a function of A
A is Determinant
8
Cont.…
Example
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
9
Cont.…
Partial Dependency
Let {A,B} is the Primary Key and C is non key attribute.
Then if {A,B}C and BC or AC
Then C is partially functionally dependent on {A,B}
Example: StudentID ProjectNo StudentName ProjectName
S01 P01 Abebe SMIS
S02 P02 Mamo Geo Location
12
Steps of Normalization
First Normal Form (1NF)
Requires that all column values in a table are atomic
We have two ways of achieving this:
1. Putting each repeating group into a separate table and
connecting them with a primary key-foreign key
relationship
2. Moving these repeating groups to a new row by
repeating the common attributes. If so then Find the key
with which you can find all data
13
Cont.…
A table (relation) is in 1NF If
There are no duplicated rows in the table. Unique
identifier
Each cell is single-valued (i.e., there are no repeating
groups).
Entries in a column (attribute, field) are of the same
kind.
14
Example: Unnormalized
15
Cont.…
Second Normal form 2NF
A table (relation) is in 2NF If
It is in 1NF and
If all non-key attributes are dependent on the entire
primary key(i.e. no partial dependency)
Example for 2NF:
16
Cont.…
It is in 1NF, there is no any repeating groups or attributes with
multi-valued property.
18
Cont.…
Third Normal Form (3NF)
Eliminate Columns Dependent on another non-Primary Key
This level avoids update and delete anomalies.
19
Cont.…
Example : Assumption: Students of same batch (same year) live in one
building or dormitory
This schema is in its 2NF since the primary key is a single attribute.
Let’s take StudID, Year and Dormitary and see the dependencies.
StudIDYear AND YearDormitary
And Year cannot determine StudID and
Dormitary cannot determine StudID
Then transitively StudIDDormitary
20
Cont.…
To convert it to a 3NF we need to remove all transitive
dependencies of non key attributes on another non-key
attribute.
The non-primary key attributes, dependent on each other will
be moved to another table and linked with the main table using
Candidate Key- Foreign Key relationship.
21