SlideShare a Scribd company logo
1 of 21
DATABASE
NORMALIZATION
Dan D’Urso
Orange Coast Database Associates
Laguna Niguel, Orange County, California
www.ocdatabases.com
slides.1@ocdatabases.com
Twitter: @ocdatabases
Database Normalization 1
DATABASE NORMALIZATION
ACTIVITY
• Activity extracted from a college textbook
• Shows how to put a database into 3rd normal form
• Explains the three normal forms, and
• The normalization process
• Additional exercises with answers at the end
Database Normalization 2
DATABASE NORMALIZATION
ACTIVITY
• Tracks large industrial equipment placed in large chemical
plants in the South
• Each piece of equipment has a unique identifier based on the
plant and equipment type
• Starting point is flat Excel spreadsheet
Database Normalization
3
NORMALIZATION
1st normal
form
2nd normal
form
(implies 1st)
3rd normal
form
(implies 2nd)
Database Normalization 4
3rd is normal goal; normal forms go all
the way to 5th but we will stick to 3rd for
this brief introductory exercise
TABLE DESCRIPTIONS
• This is a description of the original table using a common text
only notation (table name followed in parentheses by primary
keys underlined, required fields bolded, foreign keys italicized)
• Equipment (plant_name, eqpt_name, plant_mgr, ept_mfgr,
mfgr_addr)
• This is our 3rd normal form goal…
• Equipment (plant_name, eqpt_name, eqpt_mfgr)
• Plants (plant_name, plant_mgr)
• Manufacturers (eqpt_mfgr, mfgr_addr)
Database Normalization 5
1ST NORMAL FORM
• All rows unique
• All values in same column have same data type
• All columns have a unique name
• All cells atomic
• No repeating groups or multi-valued attributes
• Order of rows and columns does not matter.
Database Normalization 6
REPEATING GROUPS
• Although called groups the concept could apply to single columns
as well. For example phone numbers: work, home, cell, etc.
• Here is a simplified example with student grades
• Anomaly: what happens if there is a 3rd subject?
• You have to add two more columns, forcing redesign of forms, queries
and reports.
• Subjects and grades should be moved to a separate table with foreign
keys to the studentID.
Database Normalization 7
StudentID Subj1 Grade1 Subj2 Grade2
120 Math B French A-
MULTI-PART FIELDS
• NOT part of normalization, per-se
• But, may want to consider while looking at 1st normal form
• Example: customer_name : Bob Smith
• Split into customer_first_name: Bob, customer_last_name:
Smith
• This makes searching and sorting by last name possible (or first
name)
• Generally you would want to split the parts in a database and
recombine them via a query for reports. But this depends on
your business rules. You may want to preserve the field as is.
Database Normalization 8
DATABASE NORMALIZATION
Database Normalization 9
Violates first normal – why?
Plant
Name
Eqpt
Name
Plant
Mgr
Eqpt
Mfgr
Mfgr
Addr
ethylene Final cooler,
feed heater
Jim Smith ABC
Exchanger
1247 Locust
styrene Final cooler Bill Gunn Delta Supply 88 Canal
styrene Feed heater Bill Gunn ABC
Exchanger
1247 Locust
Primary keys underlined
1ST NORMAL FORM PROBLEM
• Violates 1st normal form
• There is a cell with both feed heater and final cooler which
violates the all cells must be atomic rule
Database Normalization 10
Plant
Name
Eqpt
Name
ethylene Final cooler,
feed heater
DATABASE NORMALIZATION
Database Normalization 11
Plant Name Eqpt Name Plant Mgr Eqpt Mfgr Mfgr Addr
ethylene Final cooler Jim Smith ABC
Exchanger
1247 Locust
ethylene Feed heater Jim Smith XYZ Pumps 432
Broadway
styrene Final cooler Bill Gunn Delta Supply 88 Canal
styrene Feed heater Bill Gunn XYZ Pumps 432
Broadway
1st Normal satisfied
2ND NORMAL FORM
• All non key fields must be dependent on the entire key, not just part of
the key
• This would be called a partial key dependency
• Partial key dependency example (composite PK is SKU, Loc) in an
inventory database which tracks quantity on hand by warehouse:
• In this example the description and price fields depend only on the SKU.
The QOH field can remain as it represents the quantity on hand in a
particular warehouse.
• The descr and price fields should be moved into their own table with a
primary key of SKU.
Database Normalization 12
SKU Loc QOH Descr Price
12a TU 15 Bolts 5.95
DATABASE NORMALIZATION
Database Normalization 13
Plant Name Eqpt Name Plant Mgr Eqpt Mfgr Mfgr Addr
ethylene Final cooler Jim Smith ABC
Exchanger
1247 Locust
ethylene Feed heater Jim Smith XYZ Pumps 432
Broadway
styrene Final cooler Bill Gunn Delta Supply 88 Canal
styrene Feed heater Bill Gunn XYZ Pumps 432
Broadway
1st Normal satisfied Still violates 2nd normal– why?
2ND NORMAL FORM PROBLEM
• Violates 2nd normal
form rule – contains a
partial key
dependency
• Plant manager
depends only on plant
name
• Plant manager should
be moved to a separate
table with plant name
as PK
Database Normalization 14
Plant Name Eqpt Name Plant Mgr
ethylene Final cooler Jim Smith
ethylene Feed heater Jim Smith
styrene Final cooler Bill Gunn
styrene Feed heater Bill Gunn
DATABASE NORMALIZATION
Database Normalization 15
Plant
Name
Eqpt
name
Eqpt
Mfgr
Mfgr
Addr
ethylene Final
cooler
ABC
Exchanger
1247 Locust
ethylene Feed
heater
XYZ Pumps 432 Broadway
styrene Final
cooler
Delta Supply 88 Canal
styrene Feed
heater
XYZ Pumps 432 Broadway
Plant
Name
Plant
Mgr
ethylene Jim Smith
styrene Bill Gunn
2nd OK - no partial
key dependencies.
3RD NORMAL FORM
• Columns must not be dependent on a non-key column
• Called a transitive dependency
• Transitive dependency example (orderID is PK)
• In this example the customer name is dependent on the customerID
which is outside the key.
• It should be moved to a separate table with customerID as the PK column
(and other columns such as address and city in a more complete example).
Database Normalization 16
OrderID
Order
Date
Order
Amount
CustomerI
D
Customer
Name
1021 12/12/2012 150.00 CA88 Bob Smith
DATABASE NORMALIZATION
Database Normalization 17
Plant
Name
Eqpt
name
Eqpt
Mfgr
Mfgr
Addr
ethylene Final
cooler
ABC
Exchanger
1247 Locust
ethylene Feed
heater
XYZ Pumps 432 Broadway
styrene Final
cooler
Delta Supply 88 Canal
styrene Feed
heater
XYZ Pumps 432 Broadway
Plant
Name
Plant
Mgr
ethylene Jim Smith
styrene Bill Gunn
2nd OK - no partial
key dependencies.
Why does it violate
3rd normal?
3RD NORMAL FORM PROBLEM
• Violates 3rd normal
form
• Contains a transitive
dependency
• If you know the
equipment mfgr you
know the address
• mfgr address should
be moved to a separate
table with eqpt mfgr
as PK
Database Normalization 18
Eqpt Mfgr Mfgr Addr
ABC
Exchanger
1247 Locust
XYZ Pumps 432 Broadway
Delta Supply 88 Canal
XYZ Pumps 432 Broadway
DATABASE NORMALIZATION
Database Normalization 19
Plant
Name
Eqpt
name
Eqpt
Mfgr
ethylene Final
cooler
ABC Exchanger
ethylene Feed
heater
XYZ Pumps
styrene Final
cooler
Delta Supply
styrene Feed
heater
XYZ Pumps
Plant
Name
Plant
Mgr
Ethylene Jim Smith
styrene Bill Gunn
EqptMfgr MfgrAddr
ABC
Exchanger
1247 Locust
Delta Supply 88 Canal
XYZ Pumps 432 Broadway
Satisfies 3rd normal form – no transitive dependencies
NORMALIZATION EXERCISES
• Normalize the following…
Scenario: recording labor time spent on factory work orders
• Labor(badgeno, workorderno, full name, salary, workorderno,
workorder_description, workorder_Budget) [hint: is there a partial key
dependency? Is there another action you might wat to take?]
• Scenario: admitting patients to a single hospital
• Patient(patientno, firstname, lastname, admission_date,
assigned_doctorno, doctor’s specialty(ies), symptom_code,
symptom_description) [hint: look for repeating groups]
• Scenario: tracking parts inventory by part # and warehouse
• Inventory(partno, warehouseid, quantity on hand, reorder qty, part
description, warehouse location)
• Do it in steps: 1st normal form, 2nd normal, 3rd
Database Normalization 20
CONCLUSION
• 3rd normal form is a common goal of normalization
• Three stages
• 1st normal form – eliminate non atomic cells, repeating groups
• 2nd normal – remove partial key dependencies
• 3rd normal – eliminate transitive dependencies
Database Normalization 21

More Related Content

What's hot

Entity relationship diagram - Concept on normalization
Entity relationship diagram - Concept on normalizationEntity relationship diagram - Concept on normalization
Entity relationship diagram - Concept on normalizationSatya Pal
 
Normalization Accepted
Normalization AcceptedNormalization Accepted
Normalization Acceptedprasaddurga
 
Normalisation - 2nd normal form
Normalisation - 2nd normal formNormalisation - 2nd normal form
Normalisation - 2nd normal formcollege
 
functional dependencies with example
functional dependencies with examplefunctional dependencies with example
functional dependencies with exampleSiddhi Viradiya
 
Bsc cs ii-dbms-u-iv-normalization
Bsc cs ii-dbms-u-iv-normalizationBsc cs ii-dbms-u-iv-normalization
Bsc cs ii-dbms-u-iv-normalizationRai University
 
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NFDatabase Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NFOum Saokosal
 
Advanced Normalization
Advanced NormalizationAdvanced Normalization
Advanced NormalizationAbdullah Khosa
 
Learn Normalization in simple language
Learn Normalization in simple languageLearn Normalization in simple language
Learn Normalization in simple languageFirstWire Apps
 
Database Normalization
Database NormalizationDatabase Normalization
Database NormalizationArun Sharma
 
Normalization i i
Normalization   i iNormalization   i i
Normalization i iGagan Deep
 
Chuẩn hóa CSDL
Chuẩn hóa CSDLChuẩn hóa CSDL
Chuẩn hóa CSDLphananhvu
 
Database Management Systems 4 - Normalization
Database Management Systems 4 - NormalizationDatabase Management Systems 4 - Normalization
Database Management Systems 4 - NormalizationNickkisha Farrell
 
Database normalization
Database normalizationDatabase normalization
Database normalizationJignesh Jain
 

What's hot (20)

Entity relationship diagram - Concept on normalization
Entity relationship diagram - Concept on normalizationEntity relationship diagram - Concept on normalization
Entity relationship diagram - Concept on normalization
 
Normalization Accepted
Normalization AcceptedNormalization Accepted
Normalization Accepted
 
Normalisation - 2nd normal form
Normalisation - 2nd normal formNormalisation - 2nd normal form
Normalisation - 2nd normal form
 
functional dependencies with example
functional dependencies with examplefunctional dependencies with example
functional dependencies with example
 
Normalization
NormalizationNormalization
Normalization
 
Bsc cs ii-dbms-u-iv-normalization
Bsc cs ii-dbms-u-iv-normalizationBsc cs ii-dbms-u-iv-normalization
Bsc cs ii-dbms-u-iv-normalization
 
Normalization in DBMS
Normalization in DBMSNormalization in DBMS
Normalization in DBMS
 
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NFDatabase Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
 
Advanced Normalization
Advanced NormalizationAdvanced Normalization
Advanced Normalization
 
Learn Normalization in simple language
Learn Normalization in simple languageLearn Normalization in simple language
Learn Normalization in simple language
 
Normalization
NormalizationNormalization
Normalization
 
Normalization in DBMS
Normalization in DBMSNormalization in DBMS
Normalization in DBMS
 
Database Normalization
Database NormalizationDatabase Normalization
Database Normalization
 
Normalization
NormalizationNormalization
Normalization
 
Normalization i i
Normalization   i iNormalization   i i
Normalization i i
 
Database normalization
Database normalizationDatabase normalization
Database normalization
 
Kumar lav
Kumar lavKumar lav
Kumar lav
 
Chuẩn hóa CSDL
Chuẩn hóa CSDLChuẩn hóa CSDL
Chuẩn hóa CSDL
 
Database Management Systems 4 - Normalization
Database Management Systems 4 - NormalizationDatabase Management Systems 4 - Normalization
Database Management Systems 4 - Normalization
 
Database normalization
Database normalizationDatabase normalization
Database normalization
 

Similar to Database Normalization

2015 x472 class 04 - central and specialty
2015 x472 class 04 - central and specialty2015 x472 class 04 - central and specialty
2015 x472 class 04 - central and specialtymichaeljmack
 
denormalization.ppt
denormalization.pptdenormalization.ppt
denormalization.pptABUSUFYAN55
 
Sql server ___________session3-normailzation
Sql server  ___________session3-normailzationSql server  ___________session3-normailzation
Sql server ___________session3-normailzationEhtisham Ali
 
Implementing Change Systems in SQL Server 2016
Implementing Change Systems in SQL Server 2016Implementing Change Systems in SQL Server 2016
Implementing Change Systems in SQL Server 2016Douglas McClurg
 
Cooling & Power Issues
Cooling & Power IssuesCooling & Power Issues
Cooling & Power Issuesinstor
 
Bits, Bytes and BTUs: Warm Water Liquid Cooling at NREL
Bits, Bytes and BTUs: Warm Water Liquid Cooling at NRELBits, Bytes and BTUs: Warm Water Liquid Cooling at NREL
Bits, Bytes and BTUs: Warm Water Liquid Cooling at NRELinside-BigData.com
 
Energy recovery presentation
Energy recovery presentationEnergy recovery presentation
Energy recovery presentationplugtrab
 
Proactively Managing Your Data Center Infrastructure
Proactively Managing Your Data Center InfrastructureProactively Managing Your Data Center Infrastructure
Proactively Managing Your Data Center Infrastructurekimotte
 
normalization-1nf-to-3nf-with-same-example.ppt
normalization-1nf-to-3nf-with-same-example.pptnormalization-1nf-to-3nf-with-same-example.ppt
normalization-1nf-to-3nf-with-same-example.pptAshishPatel366192
 
dbms-unit-_part-1.pptxeqweqweqweqweqweqweqweq
dbms-unit-_part-1.pptxeqweqweqweqweqweqweqweqdbms-unit-_part-1.pptxeqweqweqweqweqweqweqweq
dbms-unit-_part-1.pptxeqweqweqweqweqweqweqweqwrushabhsirsat
 
01 stephen-harrison solar heat pump
01 stephen-harrison solar heat pump01 stephen-harrison solar heat pump
01 stephen-harrison solar heat pumpCarlos Lehman
 

Similar to Database Normalization (20)

Normalisation and anomalies
Normalisation and anomaliesNormalisation and anomalies
Normalisation and anomalies
 
Normalization.ppt
Normalization.pptNormalization.ppt
Normalization.ppt
 
Normalization
NormalizationNormalization
Normalization
 
2015 x472 class 04 - central and specialty
2015 x472 class 04 - central and specialty2015 x472 class 04 - central and specialty
2015 x472 class 04 - central and specialty
 
denormalization.ppt
denormalization.pptdenormalization.ppt
denormalization.ppt
 
Sql server ___________session3-normailzation
Sql server  ___________session3-normailzationSql server  ___________session3-normailzation
Sql server ___________session3-normailzation
 
Sql statements function join
Sql statements function joinSql statements function join
Sql statements function join
 
Normalization.ppt
Normalization.pptNormalization.ppt
Normalization.ppt
 
Dbms & oracle
Dbms & oracleDbms & oracle
Dbms & oracle
 
Implementing Change Systems in SQL Server 2016
Implementing Change Systems in SQL Server 2016Implementing Change Systems in SQL Server 2016
Implementing Change Systems in SQL Server 2016
 
Cooling & Power Issues
Cooling & Power IssuesCooling & Power Issues
Cooling & Power Issues
 
Bits, Bytes and BTUs: Warm Water Liquid Cooling at NREL
Bits, Bytes and BTUs: Warm Water Liquid Cooling at NRELBits, Bytes and BTUs: Warm Water Liquid Cooling at NREL
Bits, Bytes and BTUs: Warm Water Liquid Cooling at NREL
 
DBMS Chapter-3.ppsx
DBMS Chapter-3.ppsxDBMS Chapter-3.ppsx
DBMS Chapter-3.ppsx
 
Energy recovery presentation
Energy recovery presentationEnergy recovery presentation
Energy recovery presentation
 
Proactively Managing Your Data Center Infrastructure
Proactively Managing Your Data Center InfrastructureProactively Managing Your Data Center Infrastructure
Proactively Managing Your Data Center Infrastructure
 
normalization-1nf-to-3nf-with-same-example.ppt
normalization-1nf-to-3nf-with-same-example.pptnormalization-1nf-to-3nf-with-same-example.ppt
normalization-1nf-to-3nf-with-same-example.ppt
 
dbms-unit-_part-1.pptxeqweqweqweqweqweqweqweq
dbms-unit-_part-1.pptxeqweqweqweqweqweqweqweqdbms-unit-_part-1.pptxeqweqweqweqweqweqweqweq
dbms-unit-_part-1.pptxeqweqweqweqweqweqweqweq
 
Condensing Boiler Optimization
Condensing Boiler OptimizationCondensing Boiler Optimization
Condensing Boiler Optimization
 
01 stephen-harrison solar heat pump
01 stephen-harrison solar heat pump01 stephen-harrison solar heat pump
01 stephen-harrison solar heat pump
 
Condensing Boiler Optimization
Condensing Boiler OptimizationCondensing Boiler Optimization
Condensing Boiler Optimization
 

More from Dan D'Urso

SQL201S Accelerated Introduction to MySQL Queries
SQL201S Accelerated Introduction to MySQL QueriesSQL201S Accelerated Introduction to MySQL Queries
SQL201S Accelerated Introduction to MySQL QueriesDan D'Urso
 
LCD201d Database Diagramming with Lucidchart
LCD201d Database Diagramming with LucidchartLCD201d Database Diagramming with Lucidchart
LCD201d Database Diagramming with LucidchartDan D'Urso
 
VIS201d Visio Database Diagramming
VIS201d Visio Database DiagrammingVIS201d Visio Database Diagramming
VIS201d Visio Database DiagrammingDan D'Urso
 
PRJ101a Project 2013 Accelerated
PRJ101a Project 2013 AcceleratedPRJ101a Project 2013 Accelerated
PRJ101a Project 2013 AcceleratedDan D'Urso
 
PRJ101xl Project Libre Basic Training
PRJ101xl Project Libre Basic TrainingPRJ101xl Project Libre Basic Training
PRJ101xl Project Libre Basic TrainingDan D'Urso
 
Introduction to coding using Python
Introduction to coding using PythonIntroduction to coding using Python
Introduction to coding using PythonDan D'Urso
 
Stem conference
Stem conferenceStem conference
Stem conferenceDan D'Urso
 
SQL200A Microsoft Access SQL Design
SQL200A Microsoft Access SQL DesignSQL200A Microsoft Access SQL Design
SQL200A Microsoft Access SQL DesignDan D'Urso
 
Microsoft access self joins
Microsoft access self joinsMicrosoft access self joins
Microsoft access self joinsDan D'Urso
 
SQL302 Intermediate SQL
SQL302 Intermediate SQLSQL302 Intermediate SQL
SQL302 Intermediate SQLDan D'Urso
 
AIN106 Access Reporting and Analysis
AIN106 Access Reporting and AnalysisAIN106 Access Reporting and Analysis
AIN106 Access Reporting and AnalysisDan D'Urso
 
SQL302 Intermediate SQL Workshop 3
SQL302 Intermediate SQL Workshop 3SQL302 Intermediate SQL Workshop 3
SQL302 Intermediate SQL Workshop 3Dan D'Urso
 
SQL302 Intermediate SQL Workshop 2
SQL302 Intermediate SQL Workshop 2SQL302 Intermediate SQL Workshop 2
SQL302 Intermediate SQL Workshop 2Dan D'Urso
 
Course Catalog
Course CatalogCourse Catalog
Course CatalogDan D'Urso
 
SQL302 Intermediate SQL Workshop 1
SQL302 Intermediate SQL Workshop 1SQL302 Intermediate SQL Workshop 1
SQL302 Intermediate SQL Workshop 1Dan D'Urso
 
SQL212 Oracle SQL Manual
SQL212 Oracle SQL ManualSQL212 Oracle SQL Manual
SQL212 Oracle SQL ManualDan D'Urso
 
SQL201W MySQL SQL Manual
SQL201W MySQL SQL ManualSQL201W MySQL SQL Manual
SQL201W MySQL SQL ManualDan D'Urso
 
SQL206 SQL Median
SQL206 SQL MedianSQL206 SQL Median
SQL206 SQL MedianDan D'Urso
 
SQL202.3 Accelerated Introduction to SQL Using SQL Server Module 3
SQL202.3 Accelerated Introduction to SQL Using SQL Server Module 3SQL202.3 Accelerated Introduction to SQL Using SQL Server Module 3
SQL202.3 Accelerated Introduction to SQL Using SQL Server Module 3Dan D'Urso
 

More from Dan D'Urso (20)

SQL201S Accelerated Introduction to MySQL Queries
SQL201S Accelerated Introduction to MySQL QueriesSQL201S Accelerated Introduction to MySQL Queries
SQL201S Accelerated Introduction to MySQL Queries
 
LCD201d Database Diagramming with Lucidchart
LCD201d Database Diagramming with LucidchartLCD201d Database Diagramming with Lucidchart
LCD201d Database Diagramming with Lucidchart
 
VIS201d Visio Database Diagramming
VIS201d Visio Database DiagrammingVIS201d Visio Database Diagramming
VIS201d Visio Database Diagramming
 
PRJ101a Project 2013 Accelerated
PRJ101a Project 2013 AcceleratedPRJ101a Project 2013 Accelerated
PRJ101a Project 2013 Accelerated
 
PRJ101xl Project Libre Basic Training
PRJ101xl Project Libre Basic TrainingPRJ101xl Project Libre Basic Training
PRJ101xl Project Libre Basic Training
 
Introduction to coding using Python
Introduction to coding using PythonIntroduction to coding using Python
Introduction to coding using Python
 
Stem conference
Stem conferenceStem conference
Stem conference
 
SQL200A Microsoft Access SQL Design
SQL200A Microsoft Access SQL DesignSQL200A Microsoft Access SQL Design
SQL200A Microsoft Access SQL Design
 
Microsoft access self joins
Microsoft access self joinsMicrosoft access self joins
Microsoft access self joins
 
SQL302 Intermediate SQL
SQL302 Intermediate SQLSQL302 Intermediate SQL
SQL302 Intermediate SQL
 
AIN106 Access Reporting and Analysis
AIN106 Access Reporting and AnalysisAIN106 Access Reporting and Analysis
AIN106 Access Reporting and Analysis
 
SQL302 Intermediate SQL Workshop 3
SQL302 Intermediate SQL Workshop 3SQL302 Intermediate SQL Workshop 3
SQL302 Intermediate SQL Workshop 3
 
SQL302 Intermediate SQL Workshop 2
SQL302 Intermediate SQL Workshop 2SQL302 Intermediate SQL Workshop 2
SQL302 Intermediate SQL Workshop 2
 
Course Catalog
Course CatalogCourse Catalog
Course Catalog
 
SQL302 Intermediate SQL Workshop 1
SQL302 Intermediate SQL Workshop 1SQL302 Intermediate SQL Workshop 1
SQL302 Intermediate SQL Workshop 1
 
SQL212 Oracle SQL Manual
SQL212 Oracle SQL ManualSQL212 Oracle SQL Manual
SQL212 Oracle SQL Manual
 
SQL201W MySQL SQL Manual
SQL201W MySQL SQL ManualSQL201W MySQL SQL Manual
SQL201W MySQL SQL Manual
 
AIN100
AIN100AIN100
AIN100
 
SQL206 SQL Median
SQL206 SQL MedianSQL206 SQL Median
SQL206 SQL Median
 
SQL202.3 Accelerated Introduction to SQL Using SQL Server Module 3
SQL202.3 Accelerated Introduction to SQL Using SQL Server Module 3SQL202.3 Accelerated Introduction to SQL Using SQL Server Module 3
SQL202.3 Accelerated Introduction to SQL Using SQL Server Module 3
 

Recently uploaded

Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxEmmanuel Dauda
 
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfKantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfSocial Samosa
 
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiLow Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiSuhani Kapoor
 
Smarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxSmarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxolyaivanovalion
 
定制英国白金汉大学毕业证(UCB毕业证书) 成绩单原版一比一
定制英国白金汉大学毕业证(UCB毕业证书)																			成绩单原版一比一定制英国白金汉大学毕业证(UCB毕业证书)																			成绩单原版一比一
定制英国白金汉大学毕业证(UCB毕业证书) 成绩单原版一比一ffjhghh
 
B2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxB2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxStephen266013
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Callshivangimorya083
 
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...Suhani Kapoor
 
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
Ukraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSUkraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSAishani27
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfLars Albertsson
 
Carero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxCarero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxolyaivanovalion
 
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls DubaiDubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls Dubaihf8803863
 
Call Girls In Mahipalpur O9654467111 Escorts Service
Call Girls In Mahipalpur O9654467111  Escorts ServiceCall Girls In Mahipalpur O9654467111  Escorts Service
Call Girls In Mahipalpur O9654467111 Escorts ServiceSapana Sha
 
Ravak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxRavak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxolyaivanovalion
 
Unveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data AnalystUnveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data AnalystSamantha Rae Coolbeth
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxJohnnyPlasten
 

Recently uploaded (20)

Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptx
 
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
 
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfKantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
 
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiLow Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
 
Smarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxSmarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptx
 
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
 
定制英国白金汉大学毕业证(UCB毕业证书) 成绩单原版一比一
定制英国白金汉大学毕业证(UCB毕业证书)																			成绩单原版一比一定制英国白金汉大学毕业证(UCB毕业证书)																			成绩单原版一比一
定制英国白金汉大学毕业证(UCB毕业证书) 成绩单原版一比一
 
B2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxB2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docx
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
 
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
 
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
Ukraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSUkraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICS
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdf
 
E-Commerce Order PredictionShraddha Kamble.pptx
E-Commerce Order PredictionShraddha Kamble.pptxE-Commerce Order PredictionShraddha Kamble.pptx
E-Commerce Order PredictionShraddha Kamble.pptx
 
Carero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxCarero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptx
 
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls DubaiDubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
 
Call Girls In Mahipalpur O9654467111 Escorts Service
Call Girls In Mahipalpur O9654467111  Escorts ServiceCall Girls In Mahipalpur O9654467111  Escorts Service
Call Girls In Mahipalpur O9654467111 Escorts Service
 
Ravak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxRavak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptx
 
Unveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data AnalystUnveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data Analyst
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptx
 

Database Normalization

  • 1. DATABASE NORMALIZATION Dan D’Urso Orange Coast Database Associates Laguna Niguel, Orange County, California www.ocdatabases.com slides.1@ocdatabases.com Twitter: @ocdatabases Database Normalization 1
  • 2. DATABASE NORMALIZATION ACTIVITY • Activity extracted from a college textbook • Shows how to put a database into 3rd normal form • Explains the three normal forms, and • The normalization process • Additional exercises with answers at the end Database Normalization 2
  • 3. DATABASE NORMALIZATION ACTIVITY • Tracks large industrial equipment placed in large chemical plants in the South • Each piece of equipment has a unique identifier based on the plant and equipment type • Starting point is flat Excel spreadsheet Database Normalization 3
  • 4. NORMALIZATION 1st normal form 2nd normal form (implies 1st) 3rd normal form (implies 2nd) Database Normalization 4 3rd is normal goal; normal forms go all the way to 5th but we will stick to 3rd for this brief introductory exercise
  • 5. TABLE DESCRIPTIONS • This is a description of the original table using a common text only notation (table name followed in parentheses by primary keys underlined, required fields bolded, foreign keys italicized) • Equipment (plant_name, eqpt_name, plant_mgr, ept_mfgr, mfgr_addr) • This is our 3rd normal form goal… • Equipment (plant_name, eqpt_name, eqpt_mfgr) • Plants (plant_name, plant_mgr) • Manufacturers (eqpt_mfgr, mfgr_addr) Database Normalization 5
  • 6. 1ST NORMAL FORM • All rows unique • All values in same column have same data type • All columns have a unique name • All cells atomic • No repeating groups or multi-valued attributes • Order of rows and columns does not matter. Database Normalization 6
  • 7. REPEATING GROUPS • Although called groups the concept could apply to single columns as well. For example phone numbers: work, home, cell, etc. • Here is a simplified example with student grades • Anomaly: what happens if there is a 3rd subject? • You have to add two more columns, forcing redesign of forms, queries and reports. • Subjects and grades should be moved to a separate table with foreign keys to the studentID. Database Normalization 7 StudentID Subj1 Grade1 Subj2 Grade2 120 Math B French A-
  • 8. MULTI-PART FIELDS • NOT part of normalization, per-se • But, may want to consider while looking at 1st normal form • Example: customer_name : Bob Smith • Split into customer_first_name: Bob, customer_last_name: Smith • This makes searching and sorting by last name possible (or first name) • Generally you would want to split the parts in a database and recombine them via a query for reports. But this depends on your business rules. You may want to preserve the field as is. Database Normalization 8
  • 9. DATABASE NORMALIZATION Database Normalization 9 Violates first normal – why? Plant Name Eqpt Name Plant Mgr Eqpt Mfgr Mfgr Addr ethylene Final cooler, feed heater Jim Smith ABC Exchanger 1247 Locust styrene Final cooler Bill Gunn Delta Supply 88 Canal styrene Feed heater Bill Gunn ABC Exchanger 1247 Locust Primary keys underlined
  • 10. 1ST NORMAL FORM PROBLEM • Violates 1st normal form • There is a cell with both feed heater and final cooler which violates the all cells must be atomic rule Database Normalization 10 Plant Name Eqpt Name ethylene Final cooler, feed heater
  • 11. DATABASE NORMALIZATION Database Normalization 11 Plant Name Eqpt Name Plant Mgr Eqpt Mfgr Mfgr Addr ethylene Final cooler Jim Smith ABC Exchanger 1247 Locust ethylene Feed heater Jim Smith XYZ Pumps 432 Broadway styrene Final cooler Bill Gunn Delta Supply 88 Canal styrene Feed heater Bill Gunn XYZ Pumps 432 Broadway 1st Normal satisfied
  • 12. 2ND NORMAL FORM • All non key fields must be dependent on the entire key, not just part of the key • This would be called a partial key dependency • Partial key dependency example (composite PK is SKU, Loc) in an inventory database which tracks quantity on hand by warehouse: • In this example the description and price fields depend only on the SKU. The QOH field can remain as it represents the quantity on hand in a particular warehouse. • The descr and price fields should be moved into their own table with a primary key of SKU. Database Normalization 12 SKU Loc QOH Descr Price 12a TU 15 Bolts 5.95
  • 13. DATABASE NORMALIZATION Database Normalization 13 Plant Name Eqpt Name Plant Mgr Eqpt Mfgr Mfgr Addr ethylene Final cooler Jim Smith ABC Exchanger 1247 Locust ethylene Feed heater Jim Smith XYZ Pumps 432 Broadway styrene Final cooler Bill Gunn Delta Supply 88 Canal styrene Feed heater Bill Gunn XYZ Pumps 432 Broadway 1st Normal satisfied Still violates 2nd normal– why?
  • 14. 2ND NORMAL FORM PROBLEM • Violates 2nd normal form rule – contains a partial key dependency • Plant manager depends only on plant name • Plant manager should be moved to a separate table with plant name as PK Database Normalization 14 Plant Name Eqpt Name Plant Mgr ethylene Final cooler Jim Smith ethylene Feed heater Jim Smith styrene Final cooler Bill Gunn styrene Feed heater Bill Gunn
  • 15. DATABASE NORMALIZATION Database Normalization 15 Plant Name Eqpt name Eqpt Mfgr Mfgr Addr ethylene Final cooler ABC Exchanger 1247 Locust ethylene Feed heater XYZ Pumps 432 Broadway styrene Final cooler Delta Supply 88 Canal styrene Feed heater XYZ Pumps 432 Broadway Plant Name Plant Mgr ethylene Jim Smith styrene Bill Gunn 2nd OK - no partial key dependencies.
  • 16. 3RD NORMAL FORM • Columns must not be dependent on a non-key column • Called a transitive dependency • Transitive dependency example (orderID is PK) • In this example the customer name is dependent on the customerID which is outside the key. • It should be moved to a separate table with customerID as the PK column (and other columns such as address and city in a more complete example). Database Normalization 16 OrderID Order Date Order Amount CustomerI D Customer Name 1021 12/12/2012 150.00 CA88 Bob Smith
  • 17. DATABASE NORMALIZATION Database Normalization 17 Plant Name Eqpt name Eqpt Mfgr Mfgr Addr ethylene Final cooler ABC Exchanger 1247 Locust ethylene Feed heater XYZ Pumps 432 Broadway styrene Final cooler Delta Supply 88 Canal styrene Feed heater XYZ Pumps 432 Broadway Plant Name Plant Mgr ethylene Jim Smith styrene Bill Gunn 2nd OK - no partial key dependencies. Why does it violate 3rd normal?
  • 18. 3RD NORMAL FORM PROBLEM • Violates 3rd normal form • Contains a transitive dependency • If you know the equipment mfgr you know the address • mfgr address should be moved to a separate table with eqpt mfgr as PK Database Normalization 18 Eqpt Mfgr Mfgr Addr ABC Exchanger 1247 Locust XYZ Pumps 432 Broadway Delta Supply 88 Canal XYZ Pumps 432 Broadway
  • 19. DATABASE NORMALIZATION Database Normalization 19 Plant Name Eqpt name Eqpt Mfgr ethylene Final cooler ABC Exchanger ethylene Feed heater XYZ Pumps styrene Final cooler Delta Supply styrene Feed heater XYZ Pumps Plant Name Plant Mgr Ethylene Jim Smith styrene Bill Gunn EqptMfgr MfgrAddr ABC Exchanger 1247 Locust Delta Supply 88 Canal XYZ Pumps 432 Broadway Satisfies 3rd normal form – no transitive dependencies
  • 20. NORMALIZATION EXERCISES • Normalize the following… Scenario: recording labor time spent on factory work orders • Labor(badgeno, workorderno, full name, salary, workorderno, workorder_description, workorder_Budget) [hint: is there a partial key dependency? Is there another action you might wat to take?] • Scenario: admitting patients to a single hospital • Patient(patientno, firstname, lastname, admission_date, assigned_doctorno, doctor’s specialty(ies), symptom_code, symptom_description) [hint: look for repeating groups] • Scenario: tracking parts inventory by part # and warehouse • Inventory(partno, warehouseid, quantity on hand, reorder qty, part description, warehouse location) • Do it in steps: 1st normal form, 2nd normal, 3rd Database Normalization 20
  • 21. CONCLUSION • 3rd normal form is a common goal of normalization • Three stages • 1st normal form – eliminate non atomic cells, repeating groups • 2nd normal – remove partial key dependencies • 3rd normal – eliminate transitive dependencies Database Normalization 21