0% found this document useful (0 votes)
22 views

Advanced Normalisation

The document discusses advanced database normalization concepts including Boyce-Codd Normal Form (BCNF), Fourth Normal Form (4NF), and Fifth Normal Form (5NF). It provides examples of relations that violate different normal forms and how to decompose them into normalized forms. The document also recaps lower normal forms like 1NF, 2NF and 3NF.

Uploaded by

figew97493
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Advanced Normalisation

The document discusses advanced database normalization concepts including Boyce-Codd Normal Form (BCNF), Fourth Normal Form (4NF), and Fifth Normal Form (5NF). It provides examples of relations that violate different normal forms and how to decompose them into normalized forms. The document also recaps lower normal forms like 1NF, 2NF and 3NF.

Uploaded by

figew97493
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 23

CET341 Advanced Normalisation

Advanced Normalisation…

… to BCNF and beyond

1
CET341 Advanced Normalisation

Contents

• Test of knowledge
• Re-cap and problems of 3NF
• Boyce-Codd Normal Form
• Fourth Normal Form
• Fifth Normal Form
• Summary

2
CET341 Advanced Normalisation

1NF

• This relation is not in 1NF – why?


• How do we convert it to be in 1NF?
JobNo ProductNo ReportDate ProductDescription Fault

137 F386 12-JUN-2006 Laptop P4 Faulty screen,

Cracked case

137 G52 12-JUN-2006 Laptop carry bag Split

138 F442 13-JUN-2006 Li-on Battery Blown cells

139 F442 15-JUN-2006 Li-on Battery Damaged case

3
CET341 Advanced Normalisation

2NF

• This relation is not in 2NF – why?


• How do we make it in 2NF?

JobNo ProductNo ReportDate Fault

137 F386 12-JUN-2006 Faulty screen

137 G52 12-JUN-2006 Split case

138 F442 13-JUN-2006 Blown cells

139 F442 15-JUN-2006 Split case

4
CET341 Advanced Normalisation

3NF

• This relation is not in 3NF – why?


• How do we make it in 3NF?
ProductNo ProductName ProductTypeCode ProductTypeDescription

F386 Laptop P4 LAP Laptop

X686 Laptop Athlon LAP Laptop

G52 Laptop carry bag ACC A Accessory

F442 Li-on Battery BATT Battery

G55 Laptop carry bag ACC B Accessory

G66 Laptop carry bag BAG Leather carry bag

5
CET341 Advanced Normalisation

Third Normal Form (3NF) - Recap

• To be in Third Normal Form (3NF) the relation


must be in 2NF and no transitive dependencies
may exist within the relation.
• A transitive dependency is when an attribute is
indirectly functionally dependent on the primary
key (that is, the dependency is through another
non-key attribute)
• A relation is in 3NF when every non-key
attribute depends on the key, the whole key, and
nothing but the key
Slide 6
CET341 Advanced Normalisation

Candidate Keys
• A relation may have more than one potential
primary key
• These are known as candidate keys:
– an attribute (or set of attributes) which are potential
primary keys NI no Student No Name
AB 12 34 56 A 01123456S Fred
CD 23 45 67 B 01145678S Jane
AD 34 68 12 G 01198765S Sarah
BD 98 54 32 E 01176542S Fred
– In this example both NI no and Student no are suitable
choices for primary key
7
CET341 Advanced Normalisation

Third Normal Form (3NF) Problems

• 3NF is inadequate when a specific situation exists:


• Codd’s original definition of 3NF cannot handle a
relation that
– has multiple candidate keys
– where those candidate keys are composite
– and the keys have attributes that overlap.
• So new stronger definition of 3NF known as
Boyce-Codd Normal Form developed.

Slide 8
CET341 Advanced Normalisation

Boyce-Codd Normal Form (BCNF)


(1974)

• To be in Boyce-Codd Normal Form (BCNF)


every determinant must be a candidate key.

Slide 9
CET341 Advanced Normalisation

BCNF Example

3NF • Choose primary key:


FD Tutor Subj 1. StudentNo, Subject
• The table is in 2NF and
StudentNo Subj Tutor
3NF
00123456s SAD Lejk
• Therefore no storage
00100223s DSD Stirk
anomalies detected
00110345s SAD Kingham
00124345s SAD Lejk
2. StudentNo, Tutor
00123456s DSD Patience
• Table is not in 2NF
00112233s SAD Kingham • Because of the
dependency Tutor  Subj
This relation has two candidate keys, i.e.: • Where Tutor is part of the
• {StudentNo, Subject} primary key
• {StudentNo, Tutor}

Slide 10
CET341 Advanced Normalisation

BCNF Example

• Tutor  Subj is the offending functional dependency


• So we decompose in exactly the same way as we have
done for 2NF and 3NF
• Our resulting decomposition is…
StudentNo Tutor*
00123456s Lejk Tutor Subj
00100223s Stirk Lejk SAD
00110345s Kingham Stirk DSD

00124345s Lejk Kingham SAD

00123456s Patience Patience DSD


00112233s Kingham

11
CET341 Advanced Normalisation

Fourth Normal Form (4NF)


(Fagin 1977)
• To be in Fourth Normal Form (4NF) the relation
must be in BCNF and the relation may not contain
multi-valued (M-V) dependencies.

• Consider a student relation showing the


relationship between student, subject studied and
the sport they do.

Slide 12
CET341 Advanced Normalisation

Fourth Normal Form (4NF) cont’d


Student relation
Student 123456S
Primary Key:(StudentNo, Subject, Sport)
takes up Skiing –
M-V D: StudentNo   Subject need to add 2 rows
StudentNo   Sport

StudentNo Subject Sport StudentNo Subject Sport


123456s SAD Swimming 123456s SAD Skiing
123456s Database Skiing
123456s Database Swimming
123456s SAD Swimming
123456s SAD Tennis 123456s Database Swimming
123456s Database Tennis 123456s SAD Tennis
111222s SE Football 123456s Database Tennis
111222s SE Football

Slide 13
CET341 Advanced Normalisation

Elimination of M-V Dependencies

Student-Subject relation Student-Sport relation


Key: (StudentNo, Subject) Key: (StudentNo, Sport)

StudentNo Subject StudentNo Sport


123456s SAD 123456s Skiing
123456s Database
123456s Swimming
111222s SE
123456s Tennis
111222s Football

Slide 14
CET341 Advanced Normalisation

Fifth Normal Form (5NF)


(Fagin 1979)
• (aka Project-Join Normal Form (PJNF))
• ‘To be in Fifth Normal Form (5NF) the relation must be in
4NF and every non-trivial join dependency must be
implied by the candidate keys’

• Nonloss (Lossless)-Join Dependency


A relation can be decomposed into n relations, the
resulting relations have the nonloss-join property –
meaning we can rejoin the resulting relations to produce
the original relation without the creation of spurious
tuples.
Slide 15
CET341 Advanced Normalisation

Fifth Normal Form (5NF) cont’d


Property_Item_Supplier relation:

• Property P10 requires a washer, PropNo Item SupplierNo


• Supplier S2 supplies property P10, P10 Washer S1
• Supplier S2 provides a washer, P10 Microwave S2
• So Supplier S2 can provide a
P20 Washer S2
washer for Property P10.

• This illustrates the cyclical nature P10 Washer S1


of the constraint. P10 Microwave S2
• If this holds then the tuple
P20 Washer S2
(P10,Washer,S2) must exist in the
original relation. P10 Washer S2
• The relation contains a join
dependency

Slide 16
CET341 Advanced Normalisation

Fifth Normal Form (5NF) cont’d

Remove the join dependency:

R1 R2 R3
Prop Item Item Supplier Prop Supplier
P10 Washer Washer S1 P10 S1
P10 Microwave Microwave S2 P10 S2
P20 Washer Washer S2 P20 S2

Slide 17
CET341 Advanced Normalisation

Fifth Normal Form (5NF) cont’d

Join R1 and R2 (on common attribute, i.e. Item) :

Prop Item Supplier


P10 Washer S1
P10 Washer S2
P10 Microwave S2
P20 Washer S1  spurious tuple
P20 Washer S2

Now join this with R3 to eliminate the spurious tuple


and produce the original relation.

Slide 18
CET341 Advanced Normalisation

5NF cont
• We join on the common attributes, which in this case is
Prop and Supplier

Prop Supplier
P10 S1
P10 S2
P20 S2

• And we find that the extra row will disappear from the result, giving
us the original result, i.e. a lossless decomposition
• i.e. all three tables must exist and be joined to be in 5NF

19
CET341 Advanced Normalisation

It doesn’t end there…


• Domain/Key Normal Form
– Based on domain as well as key constraints
– Domain constraint – values of a given attribute are taken from
some prescribed domain
– https://en.wikipedia.org/wiki/Domain-key_normal_form
• Restriction Union Normal Form
– Decomposing by restrict rather than by project
– This is the only example I can find!
http://what-when-how.com/Tutorial/topic-1114galv/Database-Desi
gn-and-Relational-Theory-167.html
• Role Modelling

Slide 20
CET341 Advanced Normalisation

• 6NF
– Defined to deal with temporal data
• Optimal Normal Form (ONF)
– Copes with relationships which can be expressed using Object
• And now there’s even a new book…

21
CET341 Advanced Normalisation

Summary
• 3NF not always adequate in relational design
– So further normalisation levels: BCNF, 4NF and 5NF
– There are other levels, e.g. Domain Key Normal Form
(DKNF)

• As a database designer we decide which is the


most appropriate level to normalise to, taking into
account storage anomalies, performance, etc.
– If you allow redundancy you have to manage it at the
application level, but be cautious

Slide 22
CET341 Advanced Normalisation

Further Reading

• Date, Database Systems 8th edition


– chapters 12, 13
• Connolly & Begg, Database Systems
– 5th and 6th edition – chapter 15
• Kroenke, Database Processing 8th edition
– chapter 5

References: Date, Connolly & Begg, Kroenke as above

Slide 23

You might also like