SlideShare a Scribd company logo
CS263 Lecture 20
Revision on Normalisation
⇒ Purpose of Normalisation
⇒ Redundancy and Data Anomalies
⇒ Repeating Groups
⇒ Functional Dependency
⇒ Transitive Dependency
⇒ Stages of Normalisation
LECTURE PLAN
Purpose of Normalisation
To avoid redundancy by storing each ‘fact’ within the
database only once.
To put data into a form that conforms to relational
principles (e.g., single valued attributes, each relation
represents one entity) - no repeating groups.
To put the data into a form that is more able to
accurately accommodate change.
To avoid certain updating ‘anomalies’.
To facilitate the enforcement of data constraints.
Example: We have the following relation that contains staff and department details:
staffNo job dept dname city
SL10 Salesman 10 Sales Stratford
SA51 Manager 20 Accounts Barking
DS40 Clerk 20 Accounts Barking
OS45 Clerk 30 Operations Barking
Redundancy and Data Anomalies
Redundant data is where we have stored the same ‘information’ more
than once. i.e., the redundant data could be removed without the loss
of information.
Insert Anomaly: We can’t insert a dept without inserting a member of
staff that works in that department
Update Anomaly:
Deletion Anomaly: By removing employee SL10 we have removed all
information pertaining to the Sales dept.
Such ‘redundancy’
could lead to the
following ‘anomalies’
Cannot update information without changing
information in many places.
Functional Dependency
Formal Definition: Attribute B is functionally dependant upon
attribute A (or a collection of attributes) if a value of A determines a
single value of attribute B at any one time.
Formal Notation: A → B This should be read as ‘A determines B’
or ‘B is functionally dependant on A’. A is called the determinant
and B is called the object of the determinant.
staffNo job dept dname
SL10 Salesman 10 Sales
SA51 Manager 20 Accounts
DS40 Clerk 20 Accounts
OS45 Clerk 30 Operations
Example:
staffNo → job
staffNo → dept
staffNo → dname
dept → dname
Functional Dependencies
Functional Dependency
Full Functional Dependency: Only of relevance with composite
determinants. This is the situation when it is necessary to use all the
attributes of the composite determinant to identify its object uniquely.
order# line# qty price
A001 001 10 200
A002 001 20 400
A002 002 20 800
A004 001 15 300
Example:
(Order#, line#) → qty
(Order#, line#) → price
Full Functional Dependencies
Compound Determinants: If more than one attribute is necessary to
determine another attribute in an entity, then such a determinant is
termed a composite determinant.
Functional Dependency
Partial Functional Dependency: This is the situation that exists if it
is necessary to only use a subset of the attributes of the composite
determinant to identify its object uniquely.
student# unit# room grade
9900100 A01 TH224 2
9900010 A01 TH224 14
9901011 A02 JS075 3
9900001 A01 TH224 16
Example:
(student#, unit#) → grade
Full Functional Dependencies
unit# → room
Partial Functional Dependencies
Repetition of data!
Transitive Dependency
Definition: A transitive dependency exists when there is an
intermediate functional dependency.
Formal Notation: If A → B and B → C, then it can be stated that
the following transitive dependency exists: A → B → C
staffNo job dept dname
SL10 Salesman 10 Sales
SA51 Manager 20 Accounts
DS40 Clerk 20 Accounts
OS45 Clerk 30 Operations
Example:
staffNo → dept
dept → dname
staffNo → dept → dname
Transitive Dependencies
Repetition of data!
Normalisation - Relational Model
Relational Database Design: All attributes in a table must be atomic,
and solely dependant upon the fully primary key of that table.
THE KEY, THE WHOLE KEY, AND NOTHING BUT THE KEY!
In order to comply with the relational model it is necessary to 1) remove
repeating groups and 2) avoid redundancy and data anomalies by remoting
partial and transitive functional dependencies.
Unnormalised
(UDF)
First normal form
(1NF)
Remove repeating groups
Second normal form
(2NF)
Remove partial dependencies
Third normal form
(3NF)
Remove transitive dependencies
Boyce-Codd normal
form (BCNF)
Remove remaining functional
dependency anomalies
Fourth normal form
(4NF)
Remove multivalued dependencies
Fifth normal form
(5NF)
Remove remaining anomalies
Stages of Normalisation
Unnormalised Normal Form (UNF)
Definition: A relation is unnormalised when it has not had any
normalisation rules applied to it, and it suffers from various anomalies.
This only tends to occur where the relation has been designed using a
‘bottom-up approach’. i.e., the capturing of attributes to a ‘Universal
Relation’ from a screen layout, manual report, manual document, etc...
Unnormalised Normal Form (UNF)
ORDER
Customer No: 001964 Order Number: 00012345
Name: Mark Campbell Order Date: 14-Feb-2002
Address: 1 The House
Leytonstone
E11 9ZZ
Product Product Unit Order Line
Number Description Price Quantity Total
T5060 Hook 5.00 5 25.00
PT42 Bolt 2.50 10 20.50
QZE48 Spanner 20.00 1 20.00
Order Total: 65.50
ORDER (order-no, order-date, cust-no, cust-name, cust-add,
(prod-no, prod-desc, unit-price, ord-qty, line-total)*, order-total
First Normal Form (1NF)
Definition: A relation is in 1NF if, and only if, all its underlying
attributes contain atomic values only.
Steps from UNF to 1NF:
Remove the outermost repeating group (and any nested repeated
groups it may contain) and create a new relation to contain it.
Add to this relation a copy of the PK of the relation immediately
enclosing it.
Name the new entity (appending the number 1 to indicate 1NF)
Determine the PK of the new entity
Repeat steps until no more repeating groups.
Remove repeating groups into a new relation
A repeating group is shown by a pair of brackets within the relational schema.
ORDER (order-no, order-date, cust-no, cust-name, cust-add,
(prod-no, prod-desc, unit-price, ord-qty, line-total)*, order-total
Example - UNF to 1NF
ORDER (order-no, order-date, cust-no, cust-name, cust-add,
(prod-no, prod-desc, unit-price, ord-qty, line-total)*, order-total
1. Remove the outermost repeating group (and any nested repeated groups it may
contain) and create a new relation to contain it. (rename original to indicate 1NF)
ORDER-1 (order-no, order-date, cust-no, cust-name, cust-add, order-total
(prod-no, prod-desc, unit-price, ord-qty, line-total)
2. Add to this relation a copy of the PK of the relation immediately enclosing it.
ORDER-1 (order-no, order-date, cust-no, cust-name, cust-add, order-total
(order-no, prod-no, prod-desc, unit-price, ord-qty, line-total)
3. Name the new entity (appending the number 1 to indicate 1NF)
ORDER-LINE-1 (order-no, prod-no, prod-desc, unit-price, ord-qty, line-total)
4. Determine the PK of the new entity
ORDER-LINE-1 (order-no, prod-no, prod-desc, unit-price, ord-qty, line-total)
Second Normal Form (2NF)
Definition: A relation is in 2NF if, and only if, it is in 1NF and every
non-key attribute is fully dependent on the primary key.
Steps from 1NF to 2NF:
Remove the offending attributes that are only partially functionally
dependent on the composite key, and place them in a new relation.
Add to this relation a copy of the attribute(s) which are the
determinants of these offending attributes. These will automatically
become the primary key of this new relation.
Name the new entity (appending the number 2 to indicate 2NF)
Rename the original entity (ending with a 2 to indicate 2NF)
Remove partial functional dependencies into a new relation
Example - 1NF to 2NF
ORDER-LINE-1 (order-no, prod-no, prod-desc, unit-price, ord-qty, line-total)
1. Remove the offending attributes that are only partially functionally dependent on
the composite key, and place them in a new relation.
ORDER-LINE-1 (order-no, prod-no, ord-qty, line-total)
(prod-desc, unit-price)
2. Add to this relation a copy of the attribute(s) which determines these offending
attributes. These will automatically become the primary key of this new relation..
(prod-no, prod-desc, unit-price)
ORDER-LINE-1 (order-no, prod-no, ord-qty, line-total)
3. Name the new entity (appending the number 2 to indicate 2NF)
PRODUCT-2 (prod-no, prod-desc, unit-price)
4. Rename the original entity (ending with a 2 to indicate 2NF)
ORDER-LINE-2 (order-no, prod-no, ord-qty, line-total)
Third Normal Form (3NF)
Definition: A relation is in 3NF if, and only if, it is in 2NF and every
non-key attribute is non-transitively dependent on the primary key.
Steps from 2NF to 3NF:
Remove the offending attributes that are transitively dependent on
non-key attribute(s), and place them in a new relation.
Add to this relation a copy of the attribute(s) which are the
determinants of these offending attributes. These will automatically
become the primary key of this new relation.
Name the new entity (appending the number 3 to indicate 3NF)
Rename the original entity (ending with a 3 to indicate 3NF)
Remove transitive dependencies into a new relation
Example - 2NF to 3NF
ORDER-2 (order-no, order-date, cust-no, cust-name, cust-add, order-total
1. Remove the offending attributes that are transitively dependent on non-key
attributes, and place them in a new relation.
(cust-name, cust-add )
ORDER-2 (order-no, order-date, cust-no, order-total
2. Add to this relation a copy of the attribute(s) which determines these offending
attributes. These will automatically become the primary key of this new relation..
(cust-no, cust-name, cust-add )
ORDER-2 (order-no, order-date, cust-no, order-total
3. Name the new entity (appending the number 3 to indicate 3NF)
CUSTOMER-3 (cust-no, cust-name, cust-add )
4. Rename the original entity (ending with a 3 to indicate 3NF)
ORDER-3 (order-no, order-date, cust-no, order-total
Example - Relations in 3NF
CUSTOMER-3 (cust-no, cust-name, cust-add )
ORDER-3 (order-no, order-date, cust-no, order-total
ORDER-LINE-2 (order-no, prod-no, ord-qty, line-total)
PRODUCT-2 (prod-no, prod-desc, unit-price)
CUSTOMER
ORDER
ORDER-LINE
PRODUCT
places placed by
contains
part of
shows
belongs to
cust-no
order-no prod-no
order-no, prod-no

More Related Content

What's hot

Database Modeling Using Entity.. Weak And Strong Entity Types
Database Modeling Using Entity.. Weak And Strong Entity TypesDatabase Modeling Using Entity.. Weak And Strong Entity Types
Database Modeling Using Entity.. Weak And Strong Entity Types
aakanksha s
 

What's hot (20)

Normalization in DBMS
Normalization in DBMSNormalization in DBMS
Normalization in DBMS
 
Normal forms
Normal formsNormal forms
Normal forms
 
NORMALIZACIÓN
NORMALIZACIÓN  NORMALIZACIÓN
NORMALIZACIÓN
 
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
FUNCTION DEPENDENCY  AND TYPES & EXAMPLEFUNCTION DEPENDENCY  AND TYPES & EXAMPLE
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
 
Functional dependency
Functional dependencyFunctional dependency
Functional dependency
 
4. plsql
4. plsql4. plsql
4. plsql
 
Normalisation and anomalies
Normalisation and anomaliesNormalisation and anomalies
Normalisation and anomalies
 
Sql
SqlSql
Sql
 
Database Normalization
Database NormalizationDatabase Normalization
Database Normalization
 
Normalization of Data Base
Normalization of Data BaseNormalization of Data Base
Normalization of Data Base
 
Normalization in DBMS
Normalization in DBMSNormalization in DBMS
Normalization in DBMS
 
Database Modeling Using Entity.. Weak And Strong Entity Types
Database Modeling Using Entity.. Weak And Strong Entity TypesDatabase Modeling Using Entity.. Weak And Strong Entity Types
Database Modeling Using Entity.. Weak And Strong Entity Types
 
Files in java
Files in javaFiles in java
Files in java
 
Unit 4 external sorting
Unit 4   external sortingUnit 4   external sorting
Unit 4 external sorting
 
Flujo datos
Flujo datosFlujo datos
Flujo datos
 
Manajemen Transaksi
Manajemen TransaksiManajemen Transaksi
Manajemen Transaksi
 
Decomposition methods in DBMS
Decomposition methods in DBMSDecomposition methods in DBMS
Decomposition methods in DBMS
 
DBMS - RAID
DBMS - RAIDDBMS - RAID
DBMS - RAID
 
Normalization in SQL | Edureka
Normalization in SQL | EdurekaNormalization in SQL | Edureka
Normalization in SQL | Edureka
 
Dbms normalization
Dbms normalizationDbms normalization
Dbms normalization
 

Similar to Normalisation

Penormalan/Normalization
Penormalan/NormalizationPenormalan/Normalization
Penormalan/Normalization
Joan Ador
 
Chuẩn hóa CSDL
Chuẩn hóa CSDLChuẩn hóa CSDL
Chuẩn hóa CSDL
phananhvu
 
Normalization by Ashwin and Tanmay
Normalization by Ashwin and TanmayNormalization by Ashwin and Tanmay
Normalization by Ashwin and Tanmay
Ashwin Dinoriya
 
A2 databases
A2 databasesA2 databases
A2 databases
c.west
 
6. Integrity and Security in DBMS
6. Integrity and Security in DBMS6. Integrity and Security in DBMS
6. Integrity and Security in DBMS
koolkampus
 
Database Management Systems Lab manual (KR20) CSE.pdf
Database Management Systems Lab manual (KR20) CSE.pdfDatabase Management Systems Lab manual (KR20) CSE.pdf
Database Management Systems Lab manual (KR20) CSE.pdf
Anvesh71
 

Similar to Normalisation (20)

Normalization
NormalizationNormalization
Normalization
 
Penormalan/Normalization
Penormalan/NormalizationPenormalan/Normalization
Penormalan/Normalization
 
Normalization
NormalizationNormalization
Normalization
 
Normalization
NormalizationNormalization
Normalization
 
Database Normalization
Database NormalizationDatabase Normalization
Database Normalization
 
Chuẩn hóa CSDL
Chuẩn hóa CSDLChuẩn hóa CSDL
Chuẩn hóa CSDL
 
Normalization
NormalizationNormalization
Normalization
 
Normalization.ppt
Normalization.pptNormalization.ppt
Normalization.ppt
 
Chapter10
Chapter10Chapter10
Chapter10
 
Normalization by Ashwin and Tanmay
Normalization by Ashwin and TanmayNormalization by Ashwin and Tanmay
Normalization by Ashwin and Tanmay
 
Normalization case
Normalization caseNormalization case
Normalization case
 
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
 
A2 databases
A2 databasesA2 databases
A2 databases
 
Ism normalization pine valley 2012
Ism normalization pine valley 2012Ism normalization pine valley 2012
Ism normalization pine valley 2012
 
Normmmalizzarion.ppt
Normmmalizzarion.pptNormmmalizzarion.ppt
Normmmalizzarion.ppt
 
UNIT 2 -PPT.pptx
UNIT 2 -PPT.pptxUNIT 2 -PPT.pptx
UNIT 2 -PPT.pptx
 
Mca ii-dbms-u-iv-structured query language
Mca ii-dbms-u-iv-structured query languageMca ii-dbms-u-iv-structured query language
Mca ii-dbms-u-iv-structured query language
 
6. Integrity and Security in DBMS
6. Integrity and Security in DBMS6. Integrity and Security in DBMS
6. Integrity and Security in DBMS
 
Chapter 2 Relational Data Model-part 3
Chapter 2 Relational Data Model-part 3Chapter 2 Relational Data Model-part 3
Chapter 2 Relational Data Model-part 3
 
Database Management Systems Lab manual (KR20) CSE.pdf
Database Management Systems Lab manual (KR20) CSE.pdfDatabase Management Systems Lab manual (KR20) CSE.pdf
Database Management Systems Lab manual (KR20) CSE.pdf
 

Recently uploaded

CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
R&R Consult
 
Laundry management system project report.pdf
Laundry management system project report.pdfLaundry management system project report.pdf
Laundry management system project report.pdf
Kamal Acharya
 
Hall booking system project report .pdf
Hall booking system project report  .pdfHall booking system project report  .pdf
Hall booking system project report .pdf
Kamal Acharya
 

Recently uploaded (20)

Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industries
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
 
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
 
Event Management System Vb Net Project Report.pdf
Event Management System Vb Net  Project Report.pdfEvent Management System Vb Net  Project Report.pdf
Event Management System Vb Net Project Report.pdf
 
Laundry management system project report.pdf
Laundry management system project report.pdfLaundry management system project report.pdf
Laundry management system project report.pdf
 
Construction method of steel structure space frame .pptx
Construction method of steel structure space frame .pptxConstruction method of steel structure space frame .pptx
Construction method of steel structure space frame .pptx
 
Hall booking system project report .pdf
Hall booking system project report  .pdfHall booking system project report  .pdf
Hall booking system project report .pdf
 
Explosives Industry manufacturing process.pdf
Explosives Industry manufacturing process.pdfExplosives Industry manufacturing process.pdf
Explosives Industry manufacturing process.pdf
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptxCloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
 
Toll tax management system project report..pdf
Toll tax management system project report..pdfToll tax management system project report..pdf
Toll tax management system project report..pdf
 
fluid mechanics gate notes . gate all pyqs answer
fluid mechanics gate notes . gate all pyqs answerfluid mechanics gate notes . gate all pyqs answer
fluid mechanics gate notes . gate all pyqs answer
 
BRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWING
BRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWINGBRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWING
BRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWING
 
Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
 
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data Stream
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data StreamKIT-601 Lecture Notes-UNIT-3.pdf Mining Data Stream
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data Stream
 
Top 13 Famous Civil Engineering Scientist
Top 13 Famous Civil Engineering ScientistTop 13 Famous Civil Engineering Scientist
Top 13 Famous Civil Engineering Scientist
 
Arduino based vehicle speed tracker project
Arduino based vehicle speed tracker projectArduino based vehicle speed tracker project
Arduino based vehicle speed tracker project
 
Peek implant persentation - Copy (1).pdf
Peek implant persentation - Copy (1).pdfPeek implant persentation - Copy (1).pdf
Peek implant persentation - Copy (1).pdf
 
RESORT MANAGEMENT AND RESERVATION SYSTEM PROJECT REPORT.pdf
RESORT MANAGEMENT AND RESERVATION SYSTEM PROJECT REPORT.pdfRESORT MANAGEMENT AND RESERVATION SYSTEM PROJECT REPORT.pdf
RESORT MANAGEMENT AND RESERVATION SYSTEM PROJECT REPORT.pdf
 

Normalisation

  • 1. CS263 Lecture 20 Revision on Normalisation
  • 2. ⇒ Purpose of Normalisation ⇒ Redundancy and Data Anomalies ⇒ Repeating Groups ⇒ Functional Dependency ⇒ Transitive Dependency ⇒ Stages of Normalisation LECTURE PLAN
  • 3. Purpose of Normalisation To avoid redundancy by storing each ‘fact’ within the database only once. To put data into a form that conforms to relational principles (e.g., single valued attributes, each relation represents one entity) - no repeating groups. To put the data into a form that is more able to accurately accommodate change. To avoid certain updating ‘anomalies’. To facilitate the enforcement of data constraints.
  • 4. Example: We have the following relation that contains staff and department details: staffNo job dept dname city SL10 Salesman 10 Sales Stratford SA51 Manager 20 Accounts Barking DS40 Clerk 20 Accounts Barking OS45 Clerk 30 Operations Barking Redundancy and Data Anomalies Redundant data is where we have stored the same ‘information’ more than once. i.e., the redundant data could be removed without the loss of information. Insert Anomaly: We can’t insert a dept without inserting a member of staff that works in that department Update Anomaly: Deletion Anomaly: By removing employee SL10 we have removed all information pertaining to the Sales dept. Such ‘redundancy’ could lead to the following ‘anomalies’ Cannot update information without changing information in many places.
  • 5. Functional Dependency Formal Definition: Attribute B is functionally dependant upon attribute A (or a collection of attributes) if a value of A determines a single value of attribute B at any one time. Formal Notation: A → B This should be read as ‘A determines B’ or ‘B is functionally dependant on A’. A is called the determinant and B is called the object of the determinant. staffNo job dept dname SL10 Salesman 10 Sales SA51 Manager 20 Accounts DS40 Clerk 20 Accounts OS45 Clerk 30 Operations Example: staffNo → job staffNo → dept staffNo → dname dept → dname Functional Dependencies
  • 6. Functional Dependency Full Functional Dependency: Only of relevance with composite determinants. This is the situation when it is necessary to use all the attributes of the composite determinant to identify its object uniquely. order# line# qty price A001 001 10 200 A002 001 20 400 A002 002 20 800 A004 001 15 300 Example: (Order#, line#) → qty (Order#, line#) → price Full Functional Dependencies Compound Determinants: If more than one attribute is necessary to determine another attribute in an entity, then such a determinant is termed a composite determinant.
  • 7. Functional Dependency Partial Functional Dependency: This is the situation that exists if it is necessary to only use a subset of the attributes of the composite determinant to identify its object uniquely. student# unit# room grade 9900100 A01 TH224 2 9900010 A01 TH224 14 9901011 A02 JS075 3 9900001 A01 TH224 16 Example: (student#, unit#) → grade Full Functional Dependencies unit# → room Partial Functional Dependencies Repetition of data!
  • 8. Transitive Dependency Definition: A transitive dependency exists when there is an intermediate functional dependency. Formal Notation: If A → B and B → C, then it can be stated that the following transitive dependency exists: A → B → C staffNo job dept dname SL10 Salesman 10 Sales SA51 Manager 20 Accounts DS40 Clerk 20 Accounts OS45 Clerk 30 Operations Example: staffNo → dept dept → dname staffNo → dept → dname Transitive Dependencies Repetition of data!
  • 9. Normalisation - Relational Model Relational Database Design: All attributes in a table must be atomic, and solely dependant upon the fully primary key of that table. THE KEY, THE WHOLE KEY, AND NOTHING BUT THE KEY! In order to comply with the relational model it is necessary to 1) remove repeating groups and 2) avoid redundancy and data anomalies by remoting partial and transitive functional dependencies.
  • 10. Unnormalised (UDF) First normal form (1NF) Remove repeating groups Second normal form (2NF) Remove partial dependencies Third normal form (3NF) Remove transitive dependencies Boyce-Codd normal form (BCNF) Remove remaining functional dependency anomalies Fourth normal form (4NF) Remove multivalued dependencies Fifth normal form (5NF) Remove remaining anomalies Stages of Normalisation
  • 11. Unnormalised Normal Form (UNF) Definition: A relation is unnormalised when it has not had any normalisation rules applied to it, and it suffers from various anomalies. This only tends to occur where the relation has been designed using a ‘bottom-up approach’. i.e., the capturing of attributes to a ‘Universal Relation’ from a screen layout, manual report, manual document, etc...
  • 12. Unnormalised Normal Form (UNF) ORDER Customer No: 001964 Order Number: 00012345 Name: Mark Campbell Order Date: 14-Feb-2002 Address: 1 The House Leytonstone E11 9ZZ Product Product Unit Order Line Number Description Price Quantity Total T5060 Hook 5.00 5 25.00 PT42 Bolt 2.50 10 20.50 QZE48 Spanner 20.00 1 20.00 Order Total: 65.50 ORDER (order-no, order-date, cust-no, cust-name, cust-add, (prod-no, prod-desc, unit-price, ord-qty, line-total)*, order-total
  • 13. First Normal Form (1NF) Definition: A relation is in 1NF if, and only if, all its underlying attributes contain atomic values only. Steps from UNF to 1NF: Remove the outermost repeating group (and any nested repeated groups it may contain) and create a new relation to contain it. Add to this relation a copy of the PK of the relation immediately enclosing it. Name the new entity (appending the number 1 to indicate 1NF) Determine the PK of the new entity Repeat steps until no more repeating groups. Remove repeating groups into a new relation A repeating group is shown by a pair of brackets within the relational schema. ORDER (order-no, order-date, cust-no, cust-name, cust-add, (prod-no, prod-desc, unit-price, ord-qty, line-total)*, order-total
  • 14. Example - UNF to 1NF ORDER (order-no, order-date, cust-no, cust-name, cust-add, (prod-no, prod-desc, unit-price, ord-qty, line-total)*, order-total 1. Remove the outermost repeating group (and any nested repeated groups it may contain) and create a new relation to contain it. (rename original to indicate 1NF) ORDER-1 (order-no, order-date, cust-no, cust-name, cust-add, order-total (prod-no, prod-desc, unit-price, ord-qty, line-total) 2. Add to this relation a copy of the PK of the relation immediately enclosing it. ORDER-1 (order-no, order-date, cust-no, cust-name, cust-add, order-total (order-no, prod-no, prod-desc, unit-price, ord-qty, line-total) 3. Name the new entity (appending the number 1 to indicate 1NF) ORDER-LINE-1 (order-no, prod-no, prod-desc, unit-price, ord-qty, line-total) 4. Determine the PK of the new entity ORDER-LINE-1 (order-no, prod-no, prod-desc, unit-price, ord-qty, line-total)
  • 15. Second Normal Form (2NF) Definition: A relation is in 2NF if, and only if, it is in 1NF and every non-key attribute is fully dependent on the primary key. Steps from 1NF to 2NF: Remove the offending attributes that are only partially functionally dependent on the composite key, and place them in a new relation. Add to this relation a copy of the attribute(s) which are the determinants of these offending attributes. These will automatically become the primary key of this new relation. Name the new entity (appending the number 2 to indicate 2NF) Rename the original entity (ending with a 2 to indicate 2NF) Remove partial functional dependencies into a new relation
  • 16. Example - 1NF to 2NF ORDER-LINE-1 (order-no, prod-no, prod-desc, unit-price, ord-qty, line-total) 1. Remove the offending attributes that are only partially functionally dependent on the composite key, and place them in a new relation. ORDER-LINE-1 (order-no, prod-no, ord-qty, line-total) (prod-desc, unit-price) 2. Add to this relation a copy of the attribute(s) which determines these offending attributes. These will automatically become the primary key of this new relation.. (prod-no, prod-desc, unit-price) ORDER-LINE-1 (order-no, prod-no, ord-qty, line-total) 3. Name the new entity (appending the number 2 to indicate 2NF) PRODUCT-2 (prod-no, prod-desc, unit-price) 4. Rename the original entity (ending with a 2 to indicate 2NF) ORDER-LINE-2 (order-no, prod-no, ord-qty, line-total)
  • 17. Third Normal Form (3NF) Definition: A relation is in 3NF if, and only if, it is in 2NF and every non-key attribute is non-transitively dependent on the primary key. Steps from 2NF to 3NF: Remove the offending attributes that are transitively dependent on non-key attribute(s), and place them in a new relation. Add to this relation a copy of the attribute(s) which are the determinants of these offending attributes. These will automatically become the primary key of this new relation. Name the new entity (appending the number 3 to indicate 3NF) Rename the original entity (ending with a 3 to indicate 3NF) Remove transitive dependencies into a new relation
  • 18. Example - 2NF to 3NF ORDER-2 (order-no, order-date, cust-no, cust-name, cust-add, order-total 1. Remove the offending attributes that are transitively dependent on non-key attributes, and place them in a new relation. (cust-name, cust-add ) ORDER-2 (order-no, order-date, cust-no, order-total 2. Add to this relation a copy of the attribute(s) which determines these offending attributes. These will automatically become the primary key of this new relation.. (cust-no, cust-name, cust-add ) ORDER-2 (order-no, order-date, cust-no, order-total 3. Name the new entity (appending the number 3 to indicate 3NF) CUSTOMER-3 (cust-no, cust-name, cust-add ) 4. Rename the original entity (ending with a 3 to indicate 3NF) ORDER-3 (order-no, order-date, cust-no, order-total
  • 19. Example - Relations in 3NF CUSTOMER-3 (cust-no, cust-name, cust-add ) ORDER-3 (order-no, order-date, cust-no, order-total ORDER-LINE-2 (order-no, prod-no, ord-qty, line-total) PRODUCT-2 (prod-no, prod-desc, unit-price) CUSTOMER ORDER ORDER-LINE PRODUCT places placed by contains part of shows belongs to cust-no order-no prod-no order-no, prod-no