Top Banner
27
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Normalization in databases
Page 2: Normalization in databases

Disclaimer: This presentation is prepared by trainees of baabtra as a part of mentoring program. This is not official document of baabtra –Mentoring PartnerBaabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd

Page 3: Normalization in databases

NORMALIZATION IN DATABASES

Subhin [email protected]/111subrutwitter.com/111subruin.linkedin.com/in/Subhin P.V8129076036

Page 4: Normalization in databases

MAIN POINTS DISCUSSED

• What normalization is and what role it plays in the database design process

• About the normal forms 1NF, 2NF, 3NF and BCNF• How normal forms can be transformed from lower

normal forms to higher normal forms

Page 5: Normalization in databases

ABOUT NORMALIZATION

• Normalization is the process of efficiently organizing data in a database.

• Two goals of normalization process: Eliminating Redundant Data Ensuring data dependencies

• The objective is to isolate data so that changes of a field can be made in just one table and then propagated through the rest of the database using the defined relationships.

Page 6: Normalization in databases

Normalization Stages

• 1NF• 2NF• 3NF• Boyce-Codd Normal Form (BCNF or 3.5NF)

Page 7: Normalization in databases

Normalization Stages

Page 8: Normalization in databases

First Normal Form (1NF)

• The values in each column of a table are atomic (No multi-value attributes allowed).

• Each table has a primary key: minimal set of attributes which can uniquely identify a record

• There are no repeating groups: two columns do not store similar information in the same table.

Page 9: Normalization in databases

Second Normal Form (2NF)

• Meet all the requirements of the first normal form.

• Remove subsets of data that apply to multiple rows of a table and place them in separate tables.

• Create relationships between these new tables and their predecessors through the use of foreign keys.

Page 10: Normalization in databases

Third Normal Form (3NF)

• Meet all the requirements of the second normal form.

• Every non-prime attribute of R is non-transitively dependent (i.e. directly dependent) on every superkey of R.

• Remove columns that are not dependent upon the primary key.

Page 11: Normalization in databases

Boyce-Codd Normal Form

• Meet all the requirements of the third normal form.

• Every determinant must be a candidate key.• Candidate Key:

Any attribute or a set of attributes together that has the eligibility to become a primary key.

Page 12: Normalization in databases

TRANSFORMATION FROM UNF TO HIGHER NORMAL FORMS USING AN EXAMPLE

• Example: Institution Having Two departments– Each Department Has 6 Different Students And Some

Courses– Each Student in a department can study more than

one Course – Each course has its course fee.– Periodically, report is generated that contains

information displayed which can be represented in a table as shown in next slide.

Page 13: Normalization in databases

Un-normalized Form Example

Page 14: Normalization in databases

Problems With The Table

– The table displays data redundancies.

– The table has Multivalued Attributes

– The table entries invite data inconsistencies.

– The data redundancies yield the following anomalies:

• Update anomalies.

• Addition anomalies.

• Deletion anomalies.

Page 15: Normalization in databases

Conversion to 1st Normal Form

Page 16: Normalization in databases

Conversion To 1st Normal Form

– ADVANTAGES• Each table has at least one minimal set of attributes

which can uniquely identify a record• The values in each column have Single Value

– DISADVANTAGES• Redundant data across multiple rows of the table is still

there• Existence of partial and transitive dependencies

Page 17: Normalization in databases

The Dependency diagram– Depicts all dependencies found within given table

structure– Helpful in getting bird’s-eye view of all

relationships among table’s attributes– Makes it less likely that will overlook an important

dependency

Page 18: Normalization in databases

Conversion to 2nd Normal Form{Dep No, Dep_name} {Stud no, Stud_name, Stud_DOB, Stud_age}{Dep No, Stud No , Course_name, Course_fee}

Department Details:

Course Details: Student Details:

Page 19: Normalization in databases

Conversion to 2nd Normal Form

• Advantages– eliminates redundant data in the table – It includes no partial dependencies:– Create separate tables for sets of values that apply

to multiple records • Disadvantages– The table contains Transitive Dependencies.– Some records depend on attributes other than

the table's primary key

Page 20: Normalization in databases

Conversion to 3rd Normal Form

Student Details:

Department Details:

Course Details:

Student course:

{Dep No, Dep_name} , {Stud no, Stud_name,Stud_DOB} , {Dep No, Stud No , Course name} , {Course_name, Course_fee}

Page 21: Normalization in databases

Conversion to 3rd Normal Form

• Advantages:– No non-key attribute depends transitively on a

candidate key– All The attributes in a table Depend on a single

primary key

Page 22: Normalization in databases

Conversion To BCNF

• A Case where The table is in 3NF but not in BCNF

Page 23: Normalization in databases

Example of BCNFfd1 clientNo, interviewDate interviewTime, staffNo, roomNo (Primary Key)fd2 staffNo, interviewDate, interviewTime clientNo (Candidate key)fd3 roomNo, interviewDate, interviewTime clientNo, staffNo (Candidate key)fd4 staffNo, interviewDate roomNo (not a candidate key)

As a consequece the ClientInterview relation may suffer from update anomalies.For example, two tuples have to be updated if the roomNo need be changed for staffNo SG5 on the 13-May-02.

ClientNo interviewDate interviewTime staffNo roomNoCR76 13-May-02 10.30 SG5 G101

CR76 13-May-02 12.00 SG5 G101CR74 13-May-02 12.00 SG37 G102CR56 1-Jul-02 10.30 SG5 G102

ClientInterview

Page 24: Normalization in databases

Example of BCNF(2)

To transform the ClientInterview relation to BCNF, we must remove the violating functional dependency by creating two new relations called Interview and SatffRoom as shown below,

Interview (clientNo, interviewDate, interviewTime, staffNo)StaffRoom(staffNo, interviewDate, roomNo)

ClientNo interviewDate interviewTime staffNoCR76 13-May-02 10.30 SG5

CR76 13-May-02 12.00 SG5CR74 13-May-02 12.00 SG37CR56 1-Jul-02 10.30 SG5

staffNo interviewDate roomNoSG5 13-May-02 G101

SG37 13-May-02 G102SG5 1-Jul-02 G102

Interview

StaffRoom

Page 25: Normalization in databases

THANKS

Page 26: Normalization in databases

If this presentation helped you, please visit our page facebook.com/baabtra and like it.

Thanks in advance.

www.baabtra.com | www.massbaab.com |www.baabte.com

Page 27: Normalization in databases

Contact Us