Date post: | 31-Dec-2015 |
Category: |
Documents |
Upload: | osborne-stokes |
View: | 226 times |
Download: | 1 times |
Module Title?
DBMS
Normalization
Module Title?
DBMS
Normalization
Normalization is the process of removing redundant data from
tables in order to improve storage efficiency, data integrity
(accuracy and consistency) and scalability (accomodates
changes).
This improvement is balanced against an increase in
complexity and potential performance losses from the joining
of the normalized tables at query-time.
Module Title?
DBMS
Steps in Normalization
Normalization can be accomplished and understood in stages,
each of which corresponds to a normal form.
A normal form is a state of a relation that results from applying
simple rules regarding functional dependencies ( or
relationships between attributes) to that relation.
Below are brief descriptions of the rules in normalization.
Module Title?
DBMS
Steps in Normalization
First Normal Form. Any multivalued attributes (also called
repeating groups) have been removed, so there is a single
value (possibly null) at the intersection of each row and column
of the table.
Second Normal Form. Any partial functional dependencies
have been removed.
Third Normal Form. Any transitive dependencies have been
removed.
Module Title?
DBMS
Steps in Normalization
Boyce/Codd normal form. Any remaining anomalies
(Deviation) that result from functional dependencies have been
removed.
Fourth normal form. Any multivalued dependencies have been
removed.
Fifth normal form. Any remaining anomalies have been
removed.
We describe and illustrate first through third normal forms only
in this section
Module Title?
DBMS
First Normal Form
A Table in which the intersection of every column and record contains
one and only value
Steps to Remove Repeating Groups
Remove the repeating columns from the original unnormalized table.
Create a new table with the primary key of the base table and the repeating
columns.
Add another appropriate column to the primary key, which ensures
uniqueness.
Create a foreign key in the new table to link back to the original
unnormalized table.
Module Title?
DBMS
Table Not Satisfying 1 NF
Module Title?
DBMS
After 1 NF……..
Branch Number
Address Branch Number Telno
B001 566443
B001 X Street BGL
B001 342342
B002 233444B002 Y Street Chennai
B002 456454
PRIMARY KEY
FOREIGN KEYPRIMARY KEY
Module Title?
DBMS
Module Title?
DBMS
Module Title?
DBMS
Module Title?
DBMS
Module Title?
DBMS
Second Normal Form
A table is in second normal form if the table is in the first
normal form and every non-primary key column is functionally
dependent upon the entire primary key.
No non-primary key column can be functionally dependent on
part of the primary key.
If A and B are 2 columns, B is fully functionally dependent on
A.B is not dependent on any subset of A.
Module Title?
DBMS
Second Normal Form
A table in the first normal form will be in second normal form if
any one of the following applies:
The primary key is composed of only one column
No non-keyed columns exist in the table.
Every non-keyed attribute is dependent on all of the columns
contained in the primary key.
Module Title?
DBMS
Second Normal Form
Steps to Remove Partial Dependencies
Determine which non-key columns are not dependent upon the
table’s entire primary key.
Remove those columns from the base table. Create a second table
with those non-keyed columns and a copy of the columns from the
primary key that they are dependent upon.
Create a foreign key from the original base table to the new table,
linking to the new primary key.
Module Title?
DBMS
Table not in 2 NF…
Staff no Branch No Branch Address
Name Position Hours per week
1 B001 X Street Bgl
Anitha Assistant 16
2 B002 Y StreetChennai
Swetha Assistant 12
1 B002 Y street Chennai
Anitha Assistant 3
2 B001 X Street Bgl
Swetha Assistant 4
Composite primary key
Module Title?
DBMS
Values in branch address can be worked out from only branch
number so table not in 2 NF.
Values in name and position columns can be worked out from
only Staff Number so table not in 2 NF.
Solution…We have to remove the fields which depend on the
partial Primary key.
Not in 2 NF…..
Module Title?
DBMS
Branch Number
Address Staff Number
Name Position
1 Anitha Assistant
B001 X Street Bgl2 Swetha AssistantB002 Y Street
Chennai
Branch Number Staff Number Hours per week
B001 1 16
B002 2 12
B001 1 4
B002 1 3
Primary keyPrimary key
Primary key
After 2 NF……..
Module Title?
DBMS
Module Title?
DBMS
A table is in third normal form if every non-keyed column is
directly dependent on the primary key, and not dependent on
another non-keyed column.
If the table is in second normal form and all of the “transitive
dependencies” are removed, then every non-keyed column is
said to be “dependent upon the key, the whole key, and
nothing but the key”.
Third Normal Form
Module Title?
DBMS
Steps to Remove Transitive Dependencies
Determine which columns are dependent on another non-keyed
column.
Remove those columns from the base table.
Create a second table with those columns and the non-key
columns that they are dependent upon.
Create a foreign key in the original table linking to the primary key
of the new table.
Third Normal Form
Module Title?
DBMS
A Table not in 3 NF…
Branch Number
Branch Address
Telno Manager No
Name
B001 X Street Bgl 543342 X001 Sridharan
B002 Ystreet Chennai
645774 X002 Shekar
Primary Key
Module Title?
DBMS
Manager name can be queried by Branch number also by
Manager no. So not in 3 NF.
Not in 3NF…..
Module Title?
DBMS
Solution: Converting to 3 NF.
Manager Number Name
X001 Sridhar
X002 Shekar
Module Title?
DBMS
Solution: Converting to 3 NF.
Branch Number Address Telno Manager Number
B001 X Street Bgl 566434 X001
B002 Y street Chennai 345667 X002
Module Title?
DBMS
Module Title?
DBMS