SlideShare a Scribd company logo
1 of 25
Normalization Algorithm
1. Identify functional dependencies (try to involve as many attributes as possible)
2. Find candidate keys by applying the inference rules
X is a candidate key iff X → A1,...,An  X and X is minimal
(in large relational schema there are usually more than one)
3. Find and mark all prime (X) and non-prime attributes
4. Choose one of the candidate keys for a primary key
(5) 1NF (your relation is already in 1NF if you have followed the
translation algorithm)
Normalization Algorithm
6. 2NF: (Make sure your tables are in 1NF.)
Question: Are there non-prime attributes functionally dependent on a part of a candidate
key?
Yes: Split the tables by moving the determining and determined attributes to a new table.
Remove the determined attributes from the old table and restart the algorithm for both
tables.
No: Continue to 3NF
7. 3NF: Make sure your tables are in 2NF.
Question: Are there non-prime attributes functionally dependent on something that is not
a candidate key?
Yes: Split the tables by moving the determining and determined attributes to a new table.
Remove the determined attributes from the old table and restart the algorithm for both
tables.
No: Continue to BCNF
8. BCNF: Make sure your tables are in 3NF.
Question: Does it exist a functional dependency for which the determinant is not a
candidate key?
Yes: Split the tables by moving the determining and determined attributes to a new table.
Remove the determined attributes from the old table and restart the algorithm for both
tables.
No: Done
Normalization
Step 1, Functional dependencies:
Assumptions:
StudentID->Personal number, StudentName Student names not unique
Course Code->Course Name, Exam Moments, Examiner Course names not unique
Examiner->Email One email per examiner
Personal Number -> Student ID Examiner is unique
Only one examiner per course
Personal Number Student Name StudentID Course Code Course Name Exam Moments Examiner Email
19890723-1324 Harry Potter harpo581 course1 dark arts {exam, practical exercise} P. McGonagall pmc@hogwarts.co.uk
19890723-1324 Harry Potter harpo581 course2 transformation {laboration, home exam} P. McGonagall pmc@hogwarts.co.uk
19890723-1324 Harry Potter harpo581 course3 potions {laboration} S. Snape ssn@hogwarts.co.uk
19880824-3422 Ron Weasley rowea982 course1 dark arts {exam, practical exercise} P. McGonagall pmc@hogwarts.co.uk
19880824-3422 Ron Weasley rowea982 course2 transformation {laboration, home exam} P. McGonagall pmc@hogwarts.co.uk
19880824-3422 Ron Weasley rowea982 course3 potions {laboration} S. Snape ssn@hogwarts.co.uk
19870922-2135 Draco Malfoy drama001 course1 dark arts {exam, practical exercise} P. McGonagall pmc@hogwarts.co.uk
19870922-2135 Draco Malfoy drama001 course3 potions {laboration} S. Snape ssn@hogwarts.co.uk
(1) Course Code → Course Name, Exam Moments, Examiner
imply Course Code → Examiner (decomposition)
(2) Course Code → Examiner and Examiner → Email
imply Course Code → Email (transitive)
(3) Course Code → Course Name, Exam Moments, Examiner
and Course Code → Email
imply Course Code → Course Name, Exam Moments,
Examiner, Email (union)
(4) Course Code → Course Name, Exam Moments, Examiner, Email
imply Course Code, StudentID → StudentID, Course Name,
Exam Moments, Examiner, Email (augmentation)
(5) Course Code, StudentID → StudentID, Course Name, Exam
Moments, Examiner, Email
imply Course Code, StudentID → Course Name, Exam
Moments, Examiner, Email (decomposition)
Step 2, Candidate keys:
(6) StudentID → Personal number, StudentName
imply Course Code, StudentID → Course Code, Personal
number, StudentName (augmentation)
(7) Course Code, StudentID → Course Code, Personal number,
StudentName imply Course Code, StudentID → Personal number,
StudentName (decomposition)
(8) (5) and (7) imply Course Code, StudentID → Personal number,
StudentName, Course Name, Exam Moments, Examiner, Email
(union)
i.e. (StudentID, Course Code) is a candidate key
Similarly (Personal Number, Course Code) is also a candidate key
Step 3, Prime attributes: Personal Number, StudentId, Course Code
Non-prime attributes: Student Name, Course Name, Exam
Moments, Examiner, Email
Step 4: We choose (Personal Number, Course Code) for primary key;
Step 5: 1NF
• 1NF: Split all non-atomic values
• Before:
• After:
6
Course Code
Exam
Moments
Personal
number Student Name StudentID Course Code Course NameExaminer Email
Personal
number
Student
Name StudentID
Course
Code
Course
Name
Exam
Moments Examiner Email
Prime attributes: Personal Number,
StudentId, Course Code
Non-prime attributes: Student
Name, Course Name, Exam
Moments, Examiner, Email
Step 6: 2NF
• 2NF: No nonprime-attribute should be dependent on part of
candidate key
• Before:
• After:
Course Code
Exam
Moments
Personal
number
Student
name StudentID Course Code Course NameExaminer Email
Course Code Exam Moments
Personal number Student name
Course Code Course Name Examiner Email
Personal number StudentID Course Code
Prime attributes: Personal Number,
StudentId, Course Code
Non-prime attributes: Student
Name, Course Name, Exam
Moments, Examiner, Email
Step 7: 3NF
• 3NF: No non-prime attribute should be dependent on any other
set of attributes which is not a candidate key
• Before:
• After:
Course Code Exam Moments
Personal number Student Name
Course Code Course Name Examiner
Examiner Email
Personal number StudentID Course Code
Course Code Exam Moments
Personal number Student name
Course Code Course Name Examiner Email
Personal number StudentID Course Code
Prime attributes: Personal Number,
StudentId, Course Code
Non-prime attributes: Student
Name, Course Name, Exam
Moments, Examiner, Email
Step 8: BCNF
• BCNF: Every determinant is a candidate key
• Before:
• After:
Course Code Exam Moments
Personal number Student name
Course Code Course Name Examiner
Examiner Email
Personal number StudentID Course Code
Course Code Exam Moments
Personal number Student Name
Course Code Course Name Examiner
Examiner Email
Personal number Course Code
Personal number StudentID
Prime attributes: Personal Number,
StudentId, Course Code
Non-prime attributes: Student
Name, Course Name, Exam
Moments, Examiner, Email
Example 0
Given the relation R(A, B, C, D, E, F) with functional
dependencies {A → BC, C → AD,
DE → F},
1. Find all the candidate keys of R. Use the inference
rules in the course to reach your conclusion. Do not
use more than one rule in each derivation step.
2. Normalize R to BCNF. Explain the process step by
step.
Step 1: The functional dependencies are given;
2023-04-15
10
Example 0 - Solution
Step 2: We now show that AE is a candidate key.
(1) A → BC implies A → C (decomposition)
(2) C → DA implies C → D (decomposition)
(3) A → C and C → D imply A → D (transitive rule (1) and (2))
(4) A → D implies AE → DE (augmentation)
(5) AE → DE and DE → F implies AE → F (transitive rule (4) and (DE → F))
(6) A → BC and A → D imply A → BCD (union (A → BC) and (3))
(7) A → BCD implies AE → BCDE (augmentation with E)
(8) AE → BCDE implies AE → BCD (decomposition)
(9) AE → BCD and AE → F implies AE → BCDF (union (8) and (5))
2023-04-15
11
Example 0 - Solution
We now show that CE is a also candidate key.
(10) C → DA implies C → A (decomposition)
(11) C → A implies CE → AE (augmentation with E)
(12) CE → AE and AE → BCDF implies CE → BCDF
(transitive rule (11) and (9))
(13) CE → BCDF implies CE → BDF (decomposition)
(14) CE → AE implies CE → A (decomposition)
(15) CE → A and CE → BCDF imply CE → ABDF (union (14) and (13))
Step 3: Prime attributes: A, C, E
Non-prime attributes B, D, F
2023-04-15
12
Example 0 - Solution
Step 5: Already in 1NF since there are no non-atomic
values
Step 6: Since A → BD violates the definition of 2NF,
we have to split the original table into: (from (6) A → BCD,
however C is prime, i.e., we may or may not move it with B and D)
R1(A,C,E,F) with AE and CE as candidate keys and
functional dependencies {AE → F, A → C, CE → F, C
→ A }
R2(A, B, D) with A as candidate key and functional
dependencies{A → BD}
Now, R1 and R2 satisfy the definition of 2NF.
2023-04-15
13
Example 0 - Solution
Step 7: Relations R1 and R2 are already in 3NF since there
are no non-prime attributes which are dependent on a set of
attributes that is not a candidate key.
Step 8: Relation R2 is in BCNF since every determinant (A
in this case) is a candidate key.
Relation R1 is not in BCNF since determinant C (or A) is not
a candidate key. Therefore, we need to split R1 into:
R11(A, E, F) with AE as candidate key and functional
dependencies {AE → F} and
R12(A, C) with A and C as candidate keys and functional
dependencies{A → C, C → A}
2023-04-15
14
Example 1
Given the relation R(A, B, C, D, E, F, G, H) with
functional dependencies {AB → CDEFGH, CD → B,
D → EFGH, E → FGH, FG → E, G → H},
1. Find all the candidate keys of R. Use the inference
rules in the course to reach your conclusion. Do not
use more than one rule in each derivation step.
2. Normalize R to 2NF. Explain the process step by
step.
Step 1: The functional dependencies are given;
2023-04-15
15
Example 1 - Solution
Step 2: The functional dependency AB → CDEFGH implies
that AB is a candidate key. We now show that ACD is also a
candidate key.
AB → CDEFGH implies AB → EFGH (decomposition)
AB → EFGH and CD → B imply ACD → EFGH
(pseudotransitive)
CD → B implies ACD → AB (augmentation)
ACD → AB implies ACD → B (decomposition)
ACD → B and ACD → EFGH imply ACD → BEFGH (union)
2023-04-15
16
Example 1 - Solution
Step 3: The solution to Step 2 implies that A, B, C and
D are prime and E, F, G and H non-prime.
Step 6: Since D → EFGH violates the definition of 2NF,
we have to split the original table into
R(A,B,C,D) with AB and ACD as candidate keys and
functional dependencies {AB → CD, CD → B}
R2(D,E,F,G,H) with D as candidate key and functional
dependencies{D → EFGH, E → FGH, FG → E, G → H}
Now, R and R2 satisfy the definition of 2NF.
2023-04-15
17
Example 2
Normalize (1NF → 2NF → 3NF → BCNF) the relation
R(A, B, C, D, E, F, G, H) with functional dependencies
F={ABC → DEFGH, D → CEF, EF → GH}. Explain
your solution step by step.
Step 1: The functional dependencies are given;
2023-04-15
18
Example 2 - Solution
Step 2: The functional dependency ABC → DEFGH implies
that ABC is a candidate key. We now show that ABD is also
a candidate key.
ABC → DEFGH implies ABC → EFGH (decomposition)
D → CEF implies D → C (decomposition)
ABC → EFGH and D → C imply ABD → EFGH
(pseudotransitive)
D → C implies ABD → C (augmentation)
ABD → C and ABD → EFGH imply ABD → CEFGH (union)
2023-04-15
19
Example 2 - Solution
Step 3: The candidate keys above imply that A, B, C
and D are prime and E, F, G and H non-prime.
Step 6: Since D → EFGH violates the definition of 2NF,
we have to split the original table into
R1(A,B,C,D) with ABC and ABD as candidate keys and
functional dependencies {ABC → D, D → C}
R2(D,E,F,G,H) with D as candidate key and functional
dependencies {D → EFGH, EF → GH}.
2023-04-15
20
Example 2 - Solution
Step 7: Now, R1 and R2 satisfy the definition of 2NF.
However, R2 does not satisfy the definition of 3NF due
to EF → GH. Then, we have to split R2 into
R21(D,E,F) with D as candidate key and functional
dependencies {D → EF}
R22(E,F,G,H) with EF as candidate key and functional
dependencies {EF → GH}.
2023-04-15
21
Example 2 - Solution
Step 8: Now, R1, R21 and R22 satisfy the definition of
3NF. However, R1 does not satisfy the definition of
BCNF due to D → C. Then, we have to split R1 into
R11(A,B,D) with candidate key A,B,D.
R12(D,C) with candidate key D
2023-04-15
22
CarSale Example
Consider the following relation CarSale(Car#,
Salesman#, Commission, DateSold, Discount).
Assume that a car may be sold by multiple salesman
and hence Car#,Salesman# is the primary key.
Additional dependencies are:
DateSold → Discount
Salesman# → Commission
Based on the given primary key, is the relation in 1NF,
2NF or 3NF? Why or why not? How would you
successively normalize it completely?
2023-04-15
23
CarSale Example - Solution
Car#,Salesman# is the primary key, that is:
Car#,Salesman# → Commission, DateSold, Discount
Step 3: Prime attributes Car#,Salesman#, the rest non-
prime;
Step 5: It is in 1NF
Step 6: Not 2NF because of Salesman# → Commission
R1 (Car#, Salesman#, DateSold, Discount)
R2 (Salesman#, Commission)
2023-04-15
24
CarSale Example
Step 7:
R1 Not in 3NF:
R1 (Car#, Salesman#, DateSold, Discount)
is not in 3NF because of DateSold → Discount
R11 (Car#, Salesman#, DateSold)
R12 (DateSold, Discount)
2023-04-15
25

More Related Content

Similar to Normalization Alg.ppt

Lesson 4 algebra 1 express simple functions in different forms
Lesson 4 algebra 1   express simple functions in different formsLesson 4 algebra 1   express simple functions in different forms
Lesson 4 algebra 1 express simple functions in different forms
Angela Phillips
 
Sept. 15, 2014
Sept. 15, 2014Sept. 15, 2014
Sept. 15, 2014
khyps13
 
Chapter 2_ Factorization & Algebraic Fractions F2.pptx
Chapter 2_ Factorization & Algebraic Fractions F2.pptxChapter 2_ Factorization & Algebraic Fractions F2.pptx
Chapter 2_ Factorization & Algebraic Fractions F2.pptx
Nurfarhana Abd sappar
 
Lovely Professional University UNIT 1 NUMBER SYSTEM.pdf
Lovely Professional University UNIT 1 NUMBER SYSTEM.pdfLovely Professional University UNIT 1 NUMBER SYSTEM.pdf
Lovely Professional University UNIT 1 NUMBER SYSTEM.pdf
khabarkus234
 

Similar to Normalization Alg.ppt (20)

Quiz on Digital Logic and Combinatorial Circuits
Quiz on Digital Logic and Combinatorial CircuitsQuiz on Digital Logic and Combinatorial Circuits
Quiz on Digital Logic and Combinatorial Circuits
 
Normalization
NormalizationNormalization
Normalization
 
R Algebra.ppt
R Algebra.pptR Algebra.ppt
R Algebra.ppt
 
nlp2.pdf
nlp2.pdfnlp2.pdf
nlp2.pdf
 
Guia limite
Guia limiteGuia limite
Guia limite
 
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NFNormalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
 
Normalization.ppt
Normalization.pptNormalization.ppt
Normalization.ppt
 
Lesson 4 algebra 1 express simple functions in different forms
Lesson 4 algebra 1   express simple functions in different formsLesson 4 algebra 1   express simple functions in different forms
Lesson 4 algebra 1 express simple functions in different forms
 
Sept. 15, 2014
Sept. 15, 2014Sept. 15, 2014
Sept. 15, 2014
 
Control Strategies in AI
Control Strategies in AIControl Strategies in AI
Control Strategies in AI
 
Informed and Uninformed search Strategies
Informed and Uninformed search StrategiesInformed and Uninformed search Strategies
Informed and Uninformed search Strategies
 
data Normalization.pdf
data Normalization.pdfdata Normalization.pdf
data Normalization.pdf
 
This quiz is open book and open notes/tutorialoutlet
This quiz is open book and open notes/tutorialoutletThis quiz is open book and open notes/tutorialoutlet
This quiz is open book and open notes/tutorialoutlet
 
DBMS Helping material
DBMS Helping materialDBMS Helping material
DBMS Helping material
 
Chapter 2_ Factorization & Algebraic Fractions F2.pptx
Chapter 2_ Factorization & Algebraic Fractions F2.pptxChapter 2_ Factorization & Algebraic Fractions F2.pptx
Chapter 2_ Factorization & Algebraic Fractions F2.pptx
 
Normalisation revision
Normalisation revisionNormalisation revision
Normalisation revision
 
Chapter5.pptx
Chapter5.pptxChapter5.pptx
Chapter5.pptx
 
K-Nearest Neighbor(KNN)
K-Nearest Neighbor(KNN)K-Nearest Neighbor(KNN)
K-Nearest Neighbor(KNN)
 
Exam1 (example with solutions)
Exam1 (example with solutions)Exam1 (example with solutions)
Exam1 (example with solutions)
 
Lovely Professional University UNIT 1 NUMBER SYSTEM.pdf
Lovely Professional University UNIT 1 NUMBER SYSTEM.pdfLovely Professional University UNIT 1 NUMBER SYSTEM.pdf
Lovely Professional University UNIT 1 NUMBER SYSTEM.pdf
 

More from Dr. Thippeswamy S.

More from Dr. Thippeswamy S. (19)

Bacterial Examination of Water of different sources.ppt
Bacterial Examination of Water of different sources.pptBacterial Examination of Water of different sources.ppt
Bacterial Examination of Water of different sources.ppt
 
Seven QC Tools New approach.pptx
Seven QC Tools New approach.pptxSeven QC Tools New approach.pptx
Seven QC Tools New approach.pptx
 
Soil Erosion.pptx
Soil Erosion.pptxSoil Erosion.pptx
Soil Erosion.pptx
 
Database Normalization.pptx
Database Normalization.pptxDatabase Normalization.pptx
Database Normalization.pptx
 
cloudapplications.pptx
cloudapplications.pptxcloudapplications.pptx
cloudapplications.pptx
 
12575474.ppt
12575474.ppt12575474.ppt
12575474.ppt
 
djypllh5r1gjbaekxgwv-signature-cc6692615bbc55079760b9b0c6636bc58ec509cd0446cb...
djypllh5r1gjbaekxgwv-signature-cc6692615bbc55079760b9b0c6636bc58ec509cd0446cb...djypllh5r1gjbaekxgwv-signature-cc6692615bbc55079760b9b0c6636bc58ec509cd0446cb...
djypllh5r1gjbaekxgwv-signature-cc6692615bbc55079760b9b0c6636bc58ec509cd0446cb...
 
deploymentmodelsofcloudcomputing-230211123637-08174981.pptx
deploymentmodelsofcloudcomputing-230211123637-08174981.pptxdeploymentmodelsofcloudcomputing-230211123637-08174981.pptx
deploymentmodelsofcloudcomputing-230211123637-08174981.pptx
 
DBMS.pptx
DBMS.pptxDBMS.pptx
DBMS.pptx
 
Normalization DBMS.ppt
Normalization DBMS.pptNormalization DBMS.ppt
Normalization DBMS.ppt
 
introduction to matlab.pptx
introduction to matlab.pptxintroduction to matlab.pptx
introduction to matlab.pptx
 
Conceptual Data Modeling
Conceptual Data ModelingConceptual Data Modeling
Conceptual Data Modeling
 
Introduction to SQL
Introduction to SQLIntroduction to SQL
Introduction to SQL
 
Chp-1.pptx
Chp-1.pptxChp-1.pptx
Chp-1.pptx
 
Mod-2.pptx
Mod-2.pptxMod-2.pptx
Mod-2.pptx
 
module 5.1.pptx
module 5.1.pptxmodule 5.1.pptx
module 5.1.pptx
 
module 5.pptx
module 5.pptxmodule 5.pptx
module 5.pptx
 
Module 2 (1).pptx
Module 2 (1).pptxModule 2 (1).pptx
Module 2 (1).pptx
 
23. Journal of Mycology and Plant pathology.pdf
23. Journal of Mycology and Plant pathology.pdf23. Journal of Mycology and Plant pathology.pdf
23. Journal of Mycology and Plant pathology.pdf
 

Recently uploaded

FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
dollysharma2066
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
ankushspencer015
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Christo Ananth
 

Recently uploaded (20)

(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 

Normalization Alg.ppt

  • 1. Normalization Algorithm 1. Identify functional dependencies (try to involve as many attributes as possible) 2. Find candidate keys by applying the inference rules X is a candidate key iff X → A1,...,An X and X is minimal (in large relational schema there are usually more than one) 3. Find and mark all prime (X) and non-prime attributes 4. Choose one of the candidate keys for a primary key (5) 1NF (your relation is already in 1NF if you have followed the translation algorithm)
  • 2. Normalization Algorithm 6. 2NF: (Make sure your tables are in 1NF.) Question: Are there non-prime attributes functionally dependent on a part of a candidate key? Yes: Split the tables by moving the determining and determined attributes to a new table. Remove the determined attributes from the old table and restart the algorithm for both tables. No: Continue to 3NF 7. 3NF: Make sure your tables are in 2NF. Question: Are there non-prime attributes functionally dependent on something that is not a candidate key? Yes: Split the tables by moving the determining and determined attributes to a new table. Remove the determined attributes from the old table and restart the algorithm for both tables. No: Continue to BCNF 8. BCNF: Make sure your tables are in 3NF. Question: Does it exist a functional dependency for which the determinant is not a candidate key? Yes: Split the tables by moving the determining and determined attributes to a new table. Remove the determined attributes from the old table and restart the algorithm for both tables. No: Done
  • 3. Normalization Step 1, Functional dependencies: Assumptions: StudentID->Personal number, StudentName Student names not unique Course Code->Course Name, Exam Moments, Examiner Course names not unique Examiner->Email One email per examiner Personal Number -> Student ID Examiner is unique Only one examiner per course Personal Number Student Name StudentID Course Code Course Name Exam Moments Examiner Email 19890723-1324 Harry Potter harpo581 course1 dark arts {exam, practical exercise} P. McGonagall pmc@hogwarts.co.uk 19890723-1324 Harry Potter harpo581 course2 transformation {laboration, home exam} P. McGonagall pmc@hogwarts.co.uk 19890723-1324 Harry Potter harpo581 course3 potions {laboration} S. Snape ssn@hogwarts.co.uk 19880824-3422 Ron Weasley rowea982 course1 dark arts {exam, practical exercise} P. McGonagall pmc@hogwarts.co.uk 19880824-3422 Ron Weasley rowea982 course2 transformation {laboration, home exam} P. McGonagall pmc@hogwarts.co.uk 19880824-3422 Ron Weasley rowea982 course3 potions {laboration} S. Snape ssn@hogwarts.co.uk 19870922-2135 Draco Malfoy drama001 course1 dark arts {exam, practical exercise} P. McGonagall pmc@hogwarts.co.uk 19870922-2135 Draco Malfoy drama001 course3 potions {laboration} S. Snape ssn@hogwarts.co.uk
  • 4. (1) Course Code → Course Name, Exam Moments, Examiner imply Course Code → Examiner (decomposition) (2) Course Code → Examiner and Examiner → Email imply Course Code → Email (transitive) (3) Course Code → Course Name, Exam Moments, Examiner and Course Code → Email imply Course Code → Course Name, Exam Moments, Examiner, Email (union) (4) Course Code → Course Name, Exam Moments, Examiner, Email imply Course Code, StudentID → StudentID, Course Name, Exam Moments, Examiner, Email (augmentation) (5) Course Code, StudentID → StudentID, Course Name, Exam Moments, Examiner, Email imply Course Code, StudentID → Course Name, Exam Moments, Examiner, Email (decomposition) Step 2, Candidate keys:
  • 5. (6) StudentID → Personal number, StudentName imply Course Code, StudentID → Course Code, Personal number, StudentName (augmentation) (7) Course Code, StudentID → Course Code, Personal number, StudentName imply Course Code, StudentID → Personal number, StudentName (decomposition) (8) (5) and (7) imply Course Code, StudentID → Personal number, StudentName, Course Name, Exam Moments, Examiner, Email (union) i.e. (StudentID, Course Code) is a candidate key Similarly (Personal Number, Course Code) is also a candidate key Step 3, Prime attributes: Personal Number, StudentId, Course Code Non-prime attributes: Student Name, Course Name, Exam Moments, Examiner, Email Step 4: We choose (Personal Number, Course Code) for primary key;
  • 6. Step 5: 1NF • 1NF: Split all non-atomic values • Before: • After: 6 Course Code Exam Moments Personal number Student Name StudentID Course Code Course NameExaminer Email Personal number Student Name StudentID Course Code Course Name Exam Moments Examiner Email Prime attributes: Personal Number, StudentId, Course Code Non-prime attributes: Student Name, Course Name, Exam Moments, Examiner, Email
  • 7. Step 6: 2NF • 2NF: No nonprime-attribute should be dependent on part of candidate key • Before: • After: Course Code Exam Moments Personal number Student name StudentID Course Code Course NameExaminer Email Course Code Exam Moments Personal number Student name Course Code Course Name Examiner Email Personal number StudentID Course Code Prime attributes: Personal Number, StudentId, Course Code Non-prime attributes: Student Name, Course Name, Exam Moments, Examiner, Email
  • 8. Step 7: 3NF • 3NF: No non-prime attribute should be dependent on any other set of attributes which is not a candidate key • Before: • After: Course Code Exam Moments Personal number Student Name Course Code Course Name Examiner Examiner Email Personal number StudentID Course Code Course Code Exam Moments Personal number Student name Course Code Course Name Examiner Email Personal number StudentID Course Code Prime attributes: Personal Number, StudentId, Course Code Non-prime attributes: Student Name, Course Name, Exam Moments, Examiner, Email
  • 9. Step 8: BCNF • BCNF: Every determinant is a candidate key • Before: • After: Course Code Exam Moments Personal number Student name Course Code Course Name Examiner Examiner Email Personal number StudentID Course Code Course Code Exam Moments Personal number Student Name Course Code Course Name Examiner Examiner Email Personal number Course Code Personal number StudentID Prime attributes: Personal Number, StudentId, Course Code Non-prime attributes: Student Name, Course Name, Exam Moments, Examiner, Email
  • 10. Example 0 Given the relation R(A, B, C, D, E, F) with functional dependencies {A → BC, C → AD, DE → F}, 1. Find all the candidate keys of R. Use the inference rules in the course to reach your conclusion. Do not use more than one rule in each derivation step. 2. Normalize R to BCNF. Explain the process step by step. Step 1: The functional dependencies are given; 2023-04-15 10
  • 11. Example 0 - Solution Step 2: We now show that AE is a candidate key. (1) A → BC implies A → C (decomposition) (2) C → DA implies C → D (decomposition) (3) A → C and C → D imply A → D (transitive rule (1) and (2)) (4) A → D implies AE → DE (augmentation) (5) AE → DE and DE → F implies AE → F (transitive rule (4) and (DE → F)) (6) A → BC and A → D imply A → BCD (union (A → BC) and (3)) (7) A → BCD implies AE → BCDE (augmentation with E) (8) AE → BCDE implies AE → BCD (decomposition) (9) AE → BCD and AE → F implies AE → BCDF (union (8) and (5)) 2023-04-15 11
  • 12. Example 0 - Solution We now show that CE is a also candidate key. (10) C → DA implies C → A (decomposition) (11) C → A implies CE → AE (augmentation with E) (12) CE → AE and AE → BCDF implies CE → BCDF (transitive rule (11) and (9)) (13) CE → BCDF implies CE → BDF (decomposition) (14) CE → AE implies CE → A (decomposition) (15) CE → A and CE → BCDF imply CE → ABDF (union (14) and (13)) Step 3: Prime attributes: A, C, E Non-prime attributes B, D, F 2023-04-15 12
  • 13. Example 0 - Solution Step 5: Already in 1NF since there are no non-atomic values Step 6: Since A → BD violates the definition of 2NF, we have to split the original table into: (from (6) A → BCD, however C is prime, i.e., we may or may not move it with B and D) R1(A,C,E,F) with AE and CE as candidate keys and functional dependencies {AE → F, A → C, CE → F, C → A } R2(A, B, D) with A as candidate key and functional dependencies{A → BD} Now, R1 and R2 satisfy the definition of 2NF. 2023-04-15 13
  • 14. Example 0 - Solution Step 7: Relations R1 and R2 are already in 3NF since there are no non-prime attributes which are dependent on a set of attributes that is not a candidate key. Step 8: Relation R2 is in BCNF since every determinant (A in this case) is a candidate key. Relation R1 is not in BCNF since determinant C (or A) is not a candidate key. Therefore, we need to split R1 into: R11(A, E, F) with AE as candidate key and functional dependencies {AE → F} and R12(A, C) with A and C as candidate keys and functional dependencies{A → C, C → A} 2023-04-15 14
  • 15. Example 1 Given the relation R(A, B, C, D, E, F, G, H) with functional dependencies {AB → CDEFGH, CD → B, D → EFGH, E → FGH, FG → E, G → H}, 1. Find all the candidate keys of R. Use the inference rules in the course to reach your conclusion. Do not use more than one rule in each derivation step. 2. Normalize R to 2NF. Explain the process step by step. Step 1: The functional dependencies are given; 2023-04-15 15
  • 16. Example 1 - Solution Step 2: The functional dependency AB → CDEFGH implies that AB is a candidate key. We now show that ACD is also a candidate key. AB → CDEFGH implies AB → EFGH (decomposition) AB → EFGH and CD → B imply ACD → EFGH (pseudotransitive) CD → B implies ACD → AB (augmentation) ACD → AB implies ACD → B (decomposition) ACD → B and ACD → EFGH imply ACD → BEFGH (union) 2023-04-15 16
  • 17. Example 1 - Solution Step 3: The solution to Step 2 implies that A, B, C and D are prime and E, F, G and H non-prime. Step 6: Since D → EFGH violates the definition of 2NF, we have to split the original table into R(A,B,C,D) with AB and ACD as candidate keys and functional dependencies {AB → CD, CD → B} R2(D,E,F,G,H) with D as candidate key and functional dependencies{D → EFGH, E → FGH, FG → E, G → H} Now, R and R2 satisfy the definition of 2NF. 2023-04-15 17
  • 18. Example 2 Normalize (1NF → 2NF → 3NF → BCNF) the relation R(A, B, C, D, E, F, G, H) with functional dependencies F={ABC → DEFGH, D → CEF, EF → GH}. Explain your solution step by step. Step 1: The functional dependencies are given; 2023-04-15 18
  • 19. Example 2 - Solution Step 2: The functional dependency ABC → DEFGH implies that ABC is a candidate key. We now show that ABD is also a candidate key. ABC → DEFGH implies ABC → EFGH (decomposition) D → CEF implies D → C (decomposition) ABC → EFGH and D → C imply ABD → EFGH (pseudotransitive) D → C implies ABD → C (augmentation) ABD → C and ABD → EFGH imply ABD → CEFGH (union) 2023-04-15 19
  • 20. Example 2 - Solution Step 3: The candidate keys above imply that A, B, C and D are prime and E, F, G and H non-prime. Step 6: Since D → EFGH violates the definition of 2NF, we have to split the original table into R1(A,B,C,D) with ABC and ABD as candidate keys and functional dependencies {ABC → D, D → C} R2(D,E,F,G,H) with D as candidate key and functional dependencies {D → EFGH, EF → GH}. 2023-04-15 20
  • 21. Example 2 - Solution Step 7: Now, R1 and R2 satisfy the definition of 2NF. However, R2 does not satisfy the definition of 3NF due to EF → GH. Then, we have to split R2 into R21(D,E,F) with D as candidate key and functional dependencies {D → EF} R22(E,F,G,H) with EF as candidate key and functional dependencies {EF → GH}. 2023-04-15 21
  • 22. Example 2 - Solution Step 8: Now, R1, R21 and R22 satisfy the definition of 3NF. However, R1 does not satisfy the definition of BCNF due to D → C. Then, we have to split R1 into R11(A,B,D) with candidate key A,B,D. R12(D,C) with candidate key D 2023-04-15 22
  • 23. CarSale Example Consider the following relation CarSale(Car#, Salesman#, Commission, DateSold, Discount). Assume that a car may be sold by multiple salesman and hence Car#,Salesman# is the primary key. Additional dependencies are: DateSold → Discount Salesman# → Commission Based on the given primary key, is the relation in 1NF, 2NF or 3NF? Why or why not? How would you successively normalize it completely? 2023-04-15 23
  • 24. CarSale Example - Solution Car#,Salesman# is the primary key, that is: Car#,Salesman# → Commission, DateSold, Discount Step 3: Prime attributes Car#,Salesman#, the rest non- prime; Step 5: It is in 1NF Step 6: Not 2NF because of Salesman# → Commission R1 (Car#, Salesman#, DateSold, Discount) R2 (Salesman#, Commission) 2023-04-15 24
  • 25. CarSale Example Step 7: R1 Not in 3NF: R1 (Car#, Salesman#, DateSold, Discount) is not in 3NF because of DateSold → Discount R11 (Car#, Salesman#, DateSold) R12 (DateSold, Discount) 2023-04-15 25

Editor's Notes

  1. Med hjälp av kommandot ”Layout” kan du välja olika utformning på sidan vad gäller placering av rubrik, text och bilder.