Normalization in database

18

description

Normalization in database

Transcript of Normalization in database

Page 1: Normalization in database
Page 2: Normalization in database

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 database

NORMALIZATION IN DATABASES

[email protected]/nithilptwitter.com/usernamein.linkedin.com/in/profilename

9995223505

Page 4: Normalization in database

NORMALIZATION• The process of efficiently organizing data in a

database.• Two goals of normalization process:

Eliminating Redundant Data Ensuring data dependencies

• Main objective: Isolate data Reduce the amount of database space Make database structure flexible Consistent throughout database

Page 5: Normalization in database

• Should not suffer from following anomalies. Update anomalies.

Insertion anomalies.

Deletion anomalies.

S_No S_name S_address Course_opted

1 smith calicut php

2 turner kannur java

3 clark wayanad java

4 smith calicut Android

Page 6: Normalization in database

Normalization Stages

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

Page 7: Normalization in database

First Normal Form (1NF)

• The values in each column of a table are atomic .

• Each table has a primary key.• There are no repeating groups.

Page 8: Normalization in database

Second Normal Form (2NF)

• Should be in 1NF.• Remove subsets of data that apply to multiple

rows of a table and place them in separate tables.

• Create relationships between tables.

Page 9: Normalization in database

Third Normal Form (3NF)

• should be 2NF.• Has no transitive functional dependencies.• Remove columns that are

not dependent upon the primary key.• To convert 2NF to 3NF, we again divide tables.

Page 10: Normalization in database

Boyce-Codd Normal Form(BCNF)

• Should be 3NF.• Every determinant must be a candidate key.• All tables can have only one primary key• Candidate Key:

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

Page 11: Normalization in database

TRANSFORMATION FROM UNF TO HIGHER NORMAL FORMS USING AN EXAMPLE

Dep_no Dep_name

Stud_no Stud_name

Stud_dob

Stud_age

Course_name

Course_fee

1 cse 101 Name 1 1990-1-01 23 java 5000

102 Name 2 1991-5-25 22 php 4000

103 Name 3 1992-3-01 21 Java,php 5000,4000

2 ec 104 Name 4 1990-2-01 23 robotics 10000

105 Name 5 1991-3-01 22 circuits 15000

106 Name 6 1992-4-01 21 robotics 10000

Page 12: Normalization in database

Conversion to 1st Normal FormDep_no Dep_

nameStud_no Stud_

nameStud_dob

Stud_age

Course_name

Course_fee

1 cse 101 Name 1 1990-1-01 23 java 5000

1 cse 102 Name 2 1991-5-25 22 php 4000

1 cse 103 Name 3 1992-3-01 21 Java 5000

1 cse 103 Name 3 1990-2-01 21 php 4000

2 ec 104 Name 4 1991-3-01 23 robotics 10000

2 ec 105 Name 5 1992-4-01 22 circuits 15000

2 ec 106 Name 6 1990-1-01 21 robotics 10000

Page 13: Normalization in database

Conversion to 2nd Normal Form

Dep_no Dep_name1 cse

2 ec

Fk_dept_id Fk_stud_id Course_name Course_fee

1 101 java 5000

1 102 php 4000

1 103 Java 5000

1 103 php 4000

2 104 robotics 10000

2 105 circuits 15000

2 106 robotics 10000

Stud_no Stud_name Stud_dob Stud_age

101 Name 1 1990-1-01 23

102 Name 2 1991-5-25 22

103 Name 3 1992-3-01 21

103 Name 3 1990-2-01 21

104 Name 4 1991-3-01 23

105 Name 5 1992-4-01 22

106 Name 6 1990-1-01 21

Page 14: Normalization in database

Course_name

Course_fee

java 5000

php 4000

robotics 10000

circuits 15000

Dep_no Dep_name

1 Cse

2 ec

Fk_dept_no Fk_Stud_no Fk_Course_name

1 101 java

1 102 php

1 103 Java

1 103 php

2 104 robotics

2 105 circuits

2 106 robotics

Stud_no Stud_name Stud_dob

101 Name 1 1990-1-01

102 Name 2 1991-5-25

103 Name 3 1992-3-01

103 Name 3 1990-2-01

104 Name 4 1991-3-01

105 Name 5 1992-4-01

106 Name 6 1990-1-01

Conversion to 3nd Normal Form

Page 15: Normalization in database

Conversion To BCNF

Page 16: Normalization in database

Class_name Roll_no name Class_teacher

Class a 1 smith Teacher a

Class a 2 turner Teacher a

Class b 1 clark Teacher b

Class c 1 allen Teacher c

Class_name Class_teacher

Class a Teacher a

Class b Teacher b

Class c Teacher c

Class_name Roll_no name

Class a 1 smith

Class a 2 turner

Class b 1 clark

Class c 1 allen

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

A Case where The table is in both in 3NF and BCNF

Page 17: Normalization in database

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 18: Normalization in database

Contact Us

Emarald Mall (Big Bazar Building)Mavoor Road, Kozhikode,Kerala, India.Ph: + 91 – 495 40 25 550

NC Complex, Near Bus StandMukkam, Kozhikode,Kerala, India.Ph: + 91 – 495 40 25 550

Start up VillageEranakulam,Kerala, India.

Email: [email protected]