Professional Documents
Culture Documents
Database CH-4
Database CH-4
Normalization
A relational database is merely a collection of data, organized in a
particular manner. The father of the relational database approach, created
a series of rules called normal forms that help define that organization.
Chapter 4 The biggest problem needed to be solved in database is data redundancy.
Why data redundancy is the problem? Because it causes: Insert Anomaly,
Functional Dependencies and Normalization Update Anomaly, Delete Anomaly
Normalization is the process of removing redundant data from your
tables to improve storage efficiency, data integrity, and scalability.
Normalization generally involves splitting existing tables into multiple
ones, which must be re-joined or linked each time a query is issued.
NORMALIZATION is the process of identifying the logical associations
between data items and designing a database that will represent such
associations but without suffering the update anomalies which are;
Insertion, Deletion and Modification Anomalies
3 4
1
6/9/2021
Example 1
ISBN Title Price Table Scheme: {ISBN, Title, Price}
0-321-32132-1 Balloon $34.00 Functional Dependencies: {ISBN} {Title} Since the type of Wine served depends on the type of Dinner, we say
0-55-123456-9 Main Street $22.95 {ISBN} {Price} Wine is functionally dependent on Dinner. Dinner Wine
0-123-45678-0 Ulysses $34.00 Since both Wine type and Fork type are determined by
1-22-233700-0 Visual $25.00
the Dinner type, we say Wine is functionally dependent
Basic on Dinner and Fork is functionally dependent on Dinner.
Dinner Wine
Dinner Fork
8
2
6/9/2021
9 10
3
6/9/2021
1. Putting each repeating group into a separate table and connecting 0-55-123456-9 Main Street Jones,
Smith
123-333-3333,
654-223-3455
Small House 714-000-0000 $22.95
them with a primary key-foreign key relationship 0-123-45678-0 Ulysses Joyce 666-666-6666 Alpha Press 999-999-9999 $34.00
2. Moving this repeating groups to a new row by repeating the common 1-22-233700-0 Visual Roman 444-444-4444 Big House 123-456-7890 $25.00
Basic
attributes. If so then Find the key with which you can find all data
Definition of a table (relation) in 1NF if:
There are no duplicated rows in the table. Unique identifier Author and AuPhone columns are not scalar
Each cell is single-valued (i.e., there are no repeating groups).
13
Entries in a column (attribute, field) are of the same kind.
0-55-123456-9 Main Street Small House 714-000-0000 $22.95 0-55-123456-9 Jones 123-333-3333
4
6/9/2021
Second Normal form 2NF … Cont’d Second Normal form 2NF … Cont’d
Example for 2NF:
As we can see some non key attributes are partially dependent on
some part of the primary key. Thus these collections of attributes
should be moved to a new relation.
This schema is in its 1NF since we don’t have any repeating groups or
attributes with multi-valued property. To convert it to a 2NF we need to
remove all partial dependencies of non key attributes on part of the
primary key.
{EmpID, ProjNo} EmpName, ProjName, ProjLoc, ProjFund,
ProjMangID
But in addition to this we have the following dependencies
EmpID EmpName
ProjNo ProjName, ProjLoc, ProjFund, ProjMangID
19 20
5
6/9/2021
Second Normal form 2NF … Cont’d Second Normal form 2NF … Cont’d
• Example 2: Normalize the following relation. So, to determine if it satisfies 2NF, you have to find out if all other
fields in it depend fully on both PatientId and RelativeId; that is,you
need to decide whether the following conditions are true:
(PatientId, RelativeId) Relationship and
(PatientId, RelativeId) Patient_tel.
However, on the dependencies in the patient table, only the following
are true:
(PatientId, RelativeId) Relationship and
(PatientId) Patient_tel.
21 22
23
6
6/9/2021
Third Normal Form (3NF ) … Cont’d Third Normal Form (3NF ) … Cont’d
Consider the following example:
Now, PK = empid
We have functional dependencies:
Empid → depid
Depid → depname
Or Depid → depbudjet
Therefore, the above table is not is 3NF. To normalize it, we can use the
functional dependencies:
Depid → depname
Depid → depbudjet And
Empid → depid
25 26