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

7-rel-db-design-07-norm2-slides

Uploaded by

etest2272
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

7-rel-db-design-07-norm2-slides

Uploaded by

etest2272
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 94

Relational Database Design

Module 7: Basic Normalization (Part 2)


Hugo Kornelis
[email protected]
Outline

 Normalization
 Functional dependencies
 Basic normal forms
 First Normal Form (1NF)
 Second Normal Form (2NF)
 Third Normal Form (3NF)
 Finding functional dependencies
Second Normal Form

 Requirements for Second Normal Form (2NF):


 Table must be in First Normal Form
 Non-key attributes must not depend on subset of any candidate key
 “Non-key attributes” – not part of any candidate key
 “Subset of candidate key” – requires at least one composite candidate key

No composite keys N o no n-key attributes


Attr 1 Attr 1
Attr 2
Attr 2 Attr 3 (AK2.1)
Attr 3
Attr 4 (AK2.1) Attr 4 (AK2.2)
Attr 5 Attr 5 (AK2.3)
Attr 6 (AK1.1) Attr 6 (AK1.1)
Second Normal Form

 Requirements for Second Normal Form (2NF):


 Table must be in First Normal Form
 Non-key attributes must not depend on subset of any candidate key
 “Non-key attributes” – not part of any candidate key
 “Subset of candidate key” – requires at least one composite candidate key

E xample
AB BE DF {B, C}  A
A
AC {B, C}  D
B (AK1.1) AD {B, C}  F
C (AK1.2)
D AE
E AF
F
Second Normal Form

 Requirements for Second Normal Form (2NF):


 Table must be in First Normal Form
 Non-key attributes must not depend on subset of any candidate key
 “Non-key attributes” – not part of any candidate key
 “Subset of candidate key” – requires at least one composite candidate key

E xample
AB BE DF {B, C}  A
A
AC {B, C}  D
B (AK1.1) AD {B, C}  F
C (AK1.2)
D AE
E AF
F
Second Normal Form

 Requirements for Second Normal Form (2NF):


 Table must be in First Normal Form
 Non-key attributes must not depend on subset of any candidate key
 “Non-key attributes” – not part of any candidate key
 “Subset of candidate key” – requires at least one composite candidate key

E xample
AB BE DF {B, C}  A
A
AC {B, C}  D
B (AK1.1) AD {B, C}  F
C (AK1.2)
D AE
E AF
F
Second Normal Form

 Requirements for Second Normal Form (2NF):


 Table must be in First Normal Form
 Non-key attributes must not depend on subset of any candidate key
 “Non-key attributes” – not part of any candidate key
 “Subset of candidate key” – requires at least one composite candidate key

E xample
AB BE DF {B, C}  A
A
AC {B, C}  D
B (AK1.1) AD {B, C}  F
C (AK1.2)
D AE
E AF
F
Second Normal Form

 Requirements for Second Normal Form (2NF):


 Table must be in First Normal Form
 Non-key attributes must not depend on subset of any candidate key
 Fixing 2NF violations:
 New entity type for offending functional dependency

E xample
Example
Fix2NF
AB BE DF {B, C}  A
A
B
AC {B, C}  D
B (AK1.1) AD {B, C}  F
C (AK1.2) B
E
D E
AE
E AF
F

Determinant = key
Second Normal Form

 Requirements for Second Normal Form (2NF):


 Table must be in First Normal Form
 Non-key attributes must not depend on subset of any candidate key
 Fixing 2NF violations:
 New entity type for offending functional dependency
 Original entity type:
 Remove dependent attributes
 Determinant implements relationship
Example
Fix2NF
AB BE DF {B, C}  A
B (FK)
A
C B
AC {B, C}  D
B (AK1.1)
(FK) (AK1.1) AD {B, C}  F
A (AK1.2)
C (AK1.1) E
D AE
E AF
F
Determinant =
foreign key
Remove dependent attribute(s)
Second Normal Form

 Requirements for Second Normal Form (2NF):


 Table must be in First Normal Form
 Non-key attributes must not depend on subset of any candidate key
 Fixing 2NF violations:
 New entity type for offending functional dependency
 Original entity type:
 Remove dependent attributes
 Determinant implements relationship
Example
Fix2NF
AB BE DF {B, C}  A
A
B
AC {B, C}  D
B (FK) (AK1.1) AD {B, C}  F
C (AK1.2) E
D AE
F AF
Finding functional dependencies, part 3

 Dependencies on subsets of candidate keys


 Violations of 2NF
 (and a few extra functional dependencies)
 Skip for tables with:
 Only single-column candidate keys
 One candidate key on all columns
 (many-to-many relationships!)
 Exactly one composite key AND no non-key columns
 Remaining tables:
 Procedure executed for each composite (multi-column) key

Test this one first Test this one later


Don’t test this one

Column A Column B Column C Column D Column E Column F Column G


Finding functional dependencies, part 3

 Dependencies on subsets of candidate keys


 Pattern to be populated:
 Columns in “current” candidate key:
 One column different, rest equal
 Columns not in “current” candidate key and not single-column key:
 One column different, rest irrelevant

Currently checking

Column A Column B Column C Column D Column E Column F Column G


a1 b1 c1 d1 ? ? ?
a2 b1 c1 d2 ? ? ?
Finding functional dependencies, part 3

 Dependencies on subsets of candidate keys


 Pattern to be populated:
 Columns in “current” candidate key:
 One column different, rest equal
 Columns not in “current” candidate key and not single-column key:
 One column different, rest irrelevant
 Optionally combine different columns
 Faster if there’s no dependency, more work if there is

Currently checking

Column A Column B Column C Column D Column E Column F Column G


a1 b1 c1 d1 e1 ? g1
a2 b1 c1 d2 e2 ? g2
Finding functional dependencies, part 3

 Dependencies on subsets of candidate keys


 Impossible to create valid example with the required pattern?
 Column with difference depends on column(s) with no difference
 Can be a normal dependency or a derivation rule
 Don’t change data model (yet)

Functional dependency found: {B, C}  D


Currently checking

Column A Column B Column C Column D Column E Column F Column G


a1 b1 c1 d1 ? ? ?
a2 b1 c1 d2 ? ? ?
Finding functional dependencies, part 3

 Dependencies on subsets of candidate keys


 Impossible to create valid example with the required pattern?
 Column with difference depends on column(s) with no difference
 Can be a normal dependency or a derivation rule
 Don’t change data model (yet)
 Continue testing
 Other columns

Functional dependency found: {B, C}  D


Currently checking

Column A Column B Column C Column D Column E Column F Column G


a1 b1 c1 d1
? e1
? ? g1
?
a2 b1 c1 d2
? e2
? ? g2
?
Finding functional dependencies, part 3

 Dependencies on subsets of candidate keys


 Impossible to create valid example with the required pattern?
 Column with difference depends on column(s) with no difference
 Can be a normal dependency or a derivation rule
 Don’t change data model (yet)
 Continue testing
 Other columns
 Other subsets of current candidate key

Functional dependency found: {B, C}  D


Currently checking

Column A Column B Column C Column D Column E Column F Column G


a1 b1 c1
a2
a1 b2
b1 c1
c2
Finding functional dependencies, part 3

 Dependencies on subsets of candidate keys


 Impossible to create valid example with the required pattern?
 Column with difference depends on column(s) with no difference
 Can be a normal dependency or a derivation rule
 Don’t change data model (yet)
 Continue testing
 Other columns
 Other subsets of current candidate key
 Other composite candidate keys

Functional dependency found: {B, C}  D


Test this one next!
Don’t test this one

Column A Column B Column C Column D Column E Column F Column G


Finding functional dependencies, part 3

 Dependencies on subsets of candidate keys


 All functional dependencies on subset of keys found
 Might not be full!

Actual dependency: A  E Actual dependency: {A, B}  E

Dependencies found: {A, B, C}  E Dependencies found: {A, B, C} 


{A, B, D}  E {A, B, D}  E
{A, C, D}  E

Column A Column B Column C Column D Column E Column F Column G


Finding functional dependencies, part 3

 Dependencies on subsets of candidate keys


 All functional dependencies on subset of keys found
 Might not be full!
Actual dependency: A  E
 Look for common subset …
 … for which every superset was found
Actual dependencies: {A, B}  E
{A, C, D}  E
Actual dependencies: {A, C}  E
{A, B, D}  E
Dependencies found: {A, B, C}  E
{A, B, D}  E Actual dependencies: {A, D}  E
{A, C, D}  E {A, B, C}  E

Column A Column B Column C Column D Column E Column F Column G


Finding functional dependencies, part 3

 Dependencies on subsets of candidate keys


 All functional dependencies on subset of keys found
 Might not be full!
Actual dependencies: {A, B}  E
 Look for common subset …
 … for which every superset was found
{A, C}  E
 Multiple common subsets possible Actual dependencies: {A, B}  E
{A, D}  E
Actual dependencies: {A, C}  E
{A, D}  E
Dependencies found: {A, B, C}  E
{A, B, D}  E Actual dependencies: {A, B}  E
{A, C, D}  E {A, C}  E
{A, D}  E

Column A Column B Column C Column D Column E Column F Column G


Finding functional dependencies, part 3

 Dependencies on subsets of candidate keys


 All functional dependencies on subset of keys found
 Might not be full!
 Look for common subset …
 … for which every superset was found
 Multiple common subsets possible

Not a dependency: {B, C}  E


would have implied: {B,C, D}  E

Dependencies found: {A, B, C}  E Not a dependency: B  E


{A, B, D}  E would have implied: {B, C, D}  E
{A, C, D}  E {B, C}  E
etcetera
Column A Column B Column C Column D Column E Column F Column G
Finding functional dependencies, part 3

 Dependencies on subsets of candidate keys


 All functional dependencies on subset of keys found
 Might not be full!
 Look for common subset …
 … for which every superset was found
 Multiple common subsets possible
 Confirmation (by testing) required
 If confirmed: Add new dependency, remove implied dependencies
 Check all possibilities!
Possible dependencies: AE
Dependencies found: {A, B, C}  E {A, B}  E
{A, B, D}  E {A, C}  E
{A, C, D}  E {A, D}  E

Column A Column B Column C Column D Column E Column F Column G


a1 b1 c1 d1 e1 ? ?
a1 b2 c1 d2 e2 ? ?
Finding functional dependencies, part 3

 Dependencies on subsets of candidate keys


 All full functional dependencies on subset of keys found
 Caused by derivation rule?  handled later
 Non-key column depends on subset of key  violates 2NF
 Create new entity type
Fix2NF Example
Example
 Remove dependent attribute
B A
A
C B
B (FK)
C
C (FK) (AK1.1)
(AK1.1)
E
DD (AK1.2)
(AK1.2)
FE (AK2.1)
GF (AK2.1)
Full functional dependencies found: {B, C}  E G
DA

Column A Column B Column C Column D Column E Column F Column G


Finding functional dependencies, part 3

 Dependencies on subsets of candidate keys


 All full functional dependencies on subset of keys found
 Caused by derivation rule?  handled later
 Non-key column depends on subset of key  violates 2NF
 Create new entity type
 Remove dependent attribute
 Subset of one key depends on subset of another key  No 2NF violation
 No schema change required

Full functional dependencies found: {B, C}  E


DA

Column A Column B Column C Column D Column E Column F Column G


Finding functional dependencies, part 3

 Dependencies on subsets of candidate keys


 All full functional dependencies on subset of keys found
 Caused by derivation rule?  handled later
 Non-key column depends on subset of key  violates 2NF
 Create new entity type
 Remove dependent attribute
 Subset of one key depends on subset of another key  No 2NF violation
 No schema change required
 (Rare) One non-key column depends on two (or more) subset of keys
 New entity type for each dependency
 Causes redundancy
 Allows data that violates dependencies
 New entity type for one of the dependencies
 Allows data that violates dependencies
 Leave original entity type unchanged
 Violates 2NF
Demo: dependencies on subsets of candidate keys Player
Player name
Functional dependencies found:
Date of birth

p lays in /
• Player 1  League
p lays in /
is played by is played by
Candidate key #2
Co mp e tition Match
League
Date (AK1.1)
Candidate key #1 Player 1 (FK) is played for / League code
P has
Player 2 (FK) (AK1.2)
League (FK)
Frames won player 1
Frames won player 2
Non-key attributes Highest break player 1 Co mp e tition Frame
Highest break player 2
Competition points player 1 c ontains / Date (FK)
Competition points player 2 is p art of P Player 1 (FK)
Frame #

Player 1 score
Player 2 score

Date Player 1 Player 2 League Frames 1 Frames 2 HB 1 HB 2 Points 1 Points 2


Demo: dependencies on subsets of candidate keys Player
Player name
Functional dependencies found:
Date of birth

p lays in /
• Player 1  League
p lays in /
is played by is played by

Co mp e tition Match
League
Date (AK1.1)
Player 1 (FK) is played for / League code
P has
Player 2 (FK) (AK1.2)
League (FK)
Frames won player 1
Frames won player 2
Highest break player 1 Co mp e tition Frame
Highest break player 2
Competition points player 1 c ontains / Date (FK)
Competition points player 2 is p art of P Player 1 (FK)
Frame #

Player 1 score
Identical values Player 2 score
Different values
Currently checking Different values

Date Player 1
?
Player 2
?
League Frames 1 Frames 2 HB 1
?
HB 2 Points 1 Points 2

2012-10-03 Katie Jim C 2 1 40 12 12 10

2013-02-07 Katie Jim C 3 0 36 12 20 0


Demo: dependencies on subsets of candidate keys Player
Player name
Functional dependencies found:
Date of birth

p lays in /
• Player 1  League
p lays in /
is played by is played by

Co mp e tition Match
League
Date (AK1.1)
Player 1 (FK) is played for / League code
P has
Player 2 (FK) (AK1.2)
League (FK)
Frames won player 1
Frames won player 2
Highest break player 1 Co mp e tition Frame
Highest break player 2
Competition points player 1 c ontains / Date (FK)
Competition points player 2 is p art of P Player 1 (FK)
Frame #

Player 1 score
Identical values Player 2 score
Different values
Currently checking Different values

Date Player 1
?
Player 2
?
League Frames 1 Frames 2 HB 1
?
HB 2 Points 1 Points 2

2012-10-03 Katie Jim C 2 1 40 12 12 10

2013-02-15 Katie Jack C 2 1 40 37 12 10


Demo: dependencies on subsets of candidate keys Player
Player name
Functional dependencies found:
Date of birth

p lays in /
• Player 1  League
p lays in /
is played by is played by

Co mp e tition Match
League
Date (AK1.1)
Player 1 (FK) is played for / League code
P has
Player 2 (FK) (AK1.2)
League (FK)
Frames won player 1
Frames won player 2
Highest break player 1 Co mp e tition Frame
Highest break player 2
Competition points player 1 c ontains / Date (FK)
Competition points player 2 is p art of P Player 1 (FK)
Frame #

Player 1 score
Identical values Player 2 score
Different values
Currently checking Different values

Date Player 1 Player 2


?
League Frames 1 Frames 2 HB 1 HB 2 Points 1 Points 2

2012-10-03 Katie Jim C 2 1 40 12 12 10

2013-02-15 Katie Jim C 2 1 40 37 12 10


Demo: dependencies on subsets of candidate keys Player
Player name
Functional dependencies found:
Date of birth

p lays in /
• Player 1  League
p lays in /
is played by is played by

Co mp e tition Match
League
Date (AK1.1)
Player 1 (FK) is played for / League code
P has
Player 2 (FK) (AK1.2)
League (FK)
Frames won player 1
Frames won player 2
Highest break player 1 Co mp e tition Frame
Highest break player 2
Competition points player 1 c ontains / Date (FK)
Competition points player 2 is p art of P Player 1 (FK)
Frame #

Player 1 score
Identical values Player 2 score
Different values
Currently checking Different values

Date Player 1 Player 2


?
League Frames 1 Frames 2 HB 1 HB 2 Points 1 Points 2

2012-10-03 Katie Jim C 2 1 40 12 12 10

2013-02-15 Katie Jim C 2 1 40 12 12 10


Demo: dependencies on subsets of candidate keys Player
Player name
Functional dependencies found:
Date of birth

p lays in /
• Player 1  League
p lays in /
is played by is played by

Co mp e tition Match
League
Date (AK1.1)
Player 1 (FK) is played for / League code
P has
Player 2 (FK) (AK1.2)
League (FK)
Frames won player 1
Frames won player 2
Highest break player 1 Co mp e tition Frame
Highest break player 2
Competition points player 1 c ontains / Date (FK)
Competition points player 2 is p art of P Player 1 (FK)
Frame #

Player 1 score
Different values Player 2 score
Identical values
Currently checking Different values

Date Player 1 Player 2 League Frames 1 Frames 2 HB 1 HB 2 Points 1 Points 2

2012-10-03 Katie Jim C 2 1 40 12 12 10

2012-10-03 Dave Mary C 3 0 36 12 20 0


Demo: dependencies on subsets of candidate keys Player
Player name
Functional dependencies found:
Date of birth

p lays in /
• Player 1  League
p lays in /
is played by is played by

Co mp e tition Match
League
Date (AK1.1)
Player 1 (FK) is played for / League code
P has
Player 2 (FK) (AK1.2)
League (FK)
Frames won player 1
Frames won player 2
Highest break player 1 Co mp e tition Frame
Highest break player 2
Competition points player 1 c ontains / Date (FK)
Competition points player 2 is p art of P Player 1 (FK)
Frame #

Player 1 score
Different values Player 2 score
Identical values
Currently checking Different values

Date Player 1 Player 2 League Frames 1 Frames 2 HB 1 HB 2 Points 1 Points 2

2012-10-03 Katie Jim C 2 1 40 12 12 10

2012-10-03 Tony Jack B 2 1 40 37 12 10


Demo: dependencies on subsets of candidate keys Player
Player name
Functional dependencies found:
Date of birth

p lays in /
• Player 1  League
p lays in /
is played by is played by

Co mp e tition Match
League
Date (AK1.1)
Player 1 (FK) is played for / League code
P has
Player 2 (FK) (AK1.2)
League (FK)
Frames won player 1
Frames won player 2
Highest break player 1 Co mp e tition Frame
Highest break player 2
Competition points player 1 c ontains / Date (FK)
Competition points player 2 is p art of P Player 1 (FK)
Frame #

Player 1 score
Identical values Player 2 score
Different values
Currently checking

Date
?
Player 1 Player 2
?
League Frames 1 Frames 2 HB 1
?
HB 2 Points 1 Points 2

2012-10-03 Katie Jim C 2 1 40 12 12 10

2013-02-07 Katie Jim C 3 0 36 12 20 0


Demo: dependencies on subsets of candidate keys Player
Player name
Functional dependencies found:
Date of birth

p lays in /
• Player 1  League
p lays in /
is played by is played by

Co mp e tition Match
League
Date (AK1.1)
Player 1 (FK) is played for / League code
P has
Player 2 (FK) (AK1.2)
League (FK)
Frames won player 1
Frames won player 2
Highest break player 1 Co mp e tition Frame
Highest break player 2
Competition points player 1 c ontains / Date (FK)
Competition points player 2 is p art of P Player 1 (FK)
Frame #

Player 1 score
Identical values Player 2 score
Different values
Currently checking

Date
?
Player 1 Player 2
?
League Frames 1 Frames 2 HB 1
?
HB 2 Points 1 Points 2

2012-10-03 Katie
? Jim C
? ? ? ? 12
? ? ?

2013-02-07 Dave
? Jim B
? ? ? ? 17
? ? ?
Demo: dependencies on subsets of candidate keys Player
Player name
Functional dependencies found:
Date of birth

p lays in /
• Player 1  League
p lays in /
is played by Player
•is played by 2  League
Co mp e tition Match
League
Date (AK1.1)
Player 1 (FK) is played for / League code
P has
Player 2 (FK) (AK1.2)
League (FK)
Frames won player 1
Frames won player 2
Highest break player 1 Co mp e tition Frame
Highest break player 2
Competition points player 1 c ontains / Date (FK)
Competition points player 2 is p art of P Player 1 (FK)
Frame #

Player 1 score
Identical values Player 2 score
Different values
Currently checking

Date
?
Player 1 Player 2
?
League Frames 1 Frames 2 HB 1
?
HB 2 Points 1 Points 2

2012-10-03 Katie Jim C 2 1 40 12 12 10

2013-02-07 Dave Jim B 3 0 36 17 20 0


Demo: dependencies on subsets of candidate keys Player
Player name
Functional dependencies found:
Date of birth

p lays in /
• Player 1  League
p lays in /
is played by Player
•is played by 2  League
Co mp e tition Match
League
Date (AK1.1)
Player 1 (FK) is played for / League code
P has
Player 2 (FK) (AK1.2)
League (FK)
Frames won player 1
Frames won player 2
Highest break player 1 Co mp e tition Frame
Highest break player 2
Competition points player 1 c ontains / Date (FK)
Competition points player 2 is p art of P Player 1 (FK)
Frame #

Player 1 score
Identical values Player 2 score
Different values
Currently checking

Date
?
Player 1 Player 2 League Frames 1 Frames 2 HB 1
?
HB 2 Points 1 Points 2

2012-10-03 Katie Jim C 2 1 40 12 12 10

2013-02-07 Dave Jim C 3 0 36 17 20 0


Demo: dependencies on subsets of candidate keys Player
Player name
Functional dependencies found:
Date of birth

p lays in /
• Player 1  League
p lays in /
is played by Player
•is played by 2  League
Co mp e tition Match
League
Date (AK1.1)
Player 1 (FK) is played for / League code
P has
Player 2 (FK) (AK1.2)
League (FK)
Frames won player 1
Frames won player 2
Highest break player 1 Co mp e tition Frame
Highest break player 2
Competition points player 1 c ontains / Date (FK)
Competition points player 2 is p art of P Player 1 (FK)
Frame #

Player 1 score
Different values Player 2 score
Identical values
Currently checking

Date Player 1 Player 2 League Frames 1 Frames 2 HB 1 HB 2 Points 1 Points 2

2012-10-03 Katie Jim C 2 1 40 12 12 10

2012-10-03 Dave Mary C 3 0 36 12 20 0


Demo: dependencies on subsets of candidate keys Player
Player name
Functional dependencies found:
Date of birth

p lays in /
• Player 1  League
p lays in /
is played by Player
•is played by 2  League
Co mp e tition Match
League
Date (AK1.1)
Player 1 (FK) is played for / League code
P has
Player 2 (FK) (AK1.2)
League (FK)
Frames won player 1
Frames won player 2
Highest break player 1 Co mp e tition Frame
Highest break player 2
Competition points player 1 c ontains / Date (FK)
Competition points player 2 is p art of P Player 1 (FK)
Frame #

Player 1 score
Different values Player 2 score
Identical values
Currently checking

Date Player 1 Player 2 League Frames 1 Frames 2 HB 1 HB 2 Points 1 Points 2

2012-10-03 Katie Jim C 2 1 40 12 12 10

2012-10-03 Tony Jack B 2 1 40 37 12 10


Demo: dependencies on subsets of candidate keys Player
Player name P la yer (2)
Date of birth Player name

League code
p lays in / p lays in /
is played by is played by

Co mp e tition Match
League
Functional dependencies found: Date (AK1.1)
is played for / League code
Player 1 (FK)
• Player 1  League Player 2 (FK) (AK1.2)
P has

• Player 2  League League (FK)


Frames won player 1
Frames won player 2
Highest break player 1 Co mp e tition Frame
Highest break player 2
Competition points player 1 c ontains / Date (FK)
Competition points player 2 is p art of P Player 1 (FK)
Actual functional dependency: Frame #

Player 1 score
• Player  League Player 2 score

Date Player 1 Player 2 League Frames 1 Frames 2 HB 1 HB 2 Points 1 Points 2


Demo: dependencies on subsets of candidate keys Player
Player name is of /
P p lays in
Date of birth
League code (FK)

p lays in / p lays in /
is played by is played by

Co mp e tition Match
League
Functional dependencies found: Date (AK1.1)
League code
Player 1 (FK)
• Player 1  League Player 2 (FK) (AK1.2)
• Player 2  League Frames won player 1
Frames won player 2
Highest break player 1
Highest break player 2 Co mp e tition Frame
Competition points player 1 c ontains /
Competition points player 2 is p art of P Date (FK)
Player 1 (FK)
Actual functional dependency: Frame #

Player 1 score
• Player  League Player 2 score

Date Player 1 Player 2 Frames 1 Frames 2 HB 1 HB 2 Points 1 Points 2


Third Normal Form

 Requirements for Third Normal Form (3NF):


 Table must be in Second Normal Form
 Non-prime attributes must be non-transitively dependent on every superkey
 or: No dependency of non-key attribute on attribute(s) that is/are not a key
 A non-key attribute depends on one non-key attribute

3NF example
Attr 1
Attr 2
Examples of violations:
Attr 3 (AK1.1)
Attr 4 (AK1.2)
• Attr5  Attr7
Attr 5 • Attr7  Attr6
Attr 6
Attr 7
Third Normal Form

 Requirements for Third Normal Form (3NF):


 Table must be in Second Normal Form
 Non-prime attributes must be non-transitively dependent on every superkey
 or: No dependency of non-key attribute on attribute(s) that is/are not a key
 A non-key attribute depends on one non-key attribute
 A non-key attribute depends on multiple non-key attributes

3NF example
Attr 1
Attr 2
Examples of violations:
Attr 3 (AK1.1)
Attr 4 (AK1.2)
• {Attr5, Attr6}  Attr7
Attr 5 • {Attr5, Attr7}  Attr6
Attr 6
Attr 7
Third Normal Form

 Requirements for Third Normal Form (3NF):


 Table must be in Second Normal Form
 Non-prime attributes must be non-transitively dependent on every superkey
 or: No dependency of non-key attribute on attribute(s) that is/are not a key
 A non-key attribute depends on one non-key attribute
 A non-key attribute depends on multiple non-key attributes
 A non-key attribute depends on combination of candidate key subset and non-key

3NF example
Attr 1
Attr 2
Examples of violations:
Attr 3 (AK1.1)
Attr 4 (AK1.2)
• {Attr1, Attr5}  Attr7
Attr 5 • {Attr3, Attr5, Attr7}  Attr6
Attr 6
Attr 7
Third Normal Form

 Requirements for Third Normal Form (3NF):


 Table must be in Second Normal Form
 Non-prime attributes must be non-transitively dependent on every superkey
 or: No dependency of non-key attribute on attribute(s) that is/are not a key
 A non-key attribute depends on one non-key attribute
 A non-key attribute depends on multiple non-key attributes
 A non-key attribute depends on combination of candidate key subset and non-key
 A non-key attribute depends on combination of multiple candidate key subsets

3NF example
Attr 1
Attr 2
Examples of violations:
Attr 3 (AK1.1)
Attr 4 (AK1.2)
• {Attr1, Attr4}  Attr6
Attr 5 • {Attr2, Attr3}  Attr6
Attr 6 • {Attr2, Attr3, Attr5, Attr6}  Attr7
Attr 7
Third Normal Form

 Requirements for Third Normal Form (3NF):


 Table must be in Second Normal Form
 Non-prime attributes must be non-transitively dependent on every superkey
 or: No dependency of non-key attribute on attribute(s) that is/are not a key
 A non-key attribute depends on one non-key attribute
 A non-key attribute depends on multiple non-key attributes
 A non-key attribute depends on combination of candidate key subset and non-key
 A non-key attribute depends on combination of multiple candidate key subsets

Example
Fix2NF
AB DF {B, C}  A
A
B
AC {B, C}  D
B (FK) (AK1.1) AD {B, C}  F
C (AK1.2) E
D AF
F
Third Normal Form

 Requirements for Third Normal Form (3NF):


 Table must be in Second Normal Form
 Non-prime attributes must be non-transitively dependent on every superkey
 or: No dependency of non-key attribute on attribute(s) that is/are not a key
 Fixing 3NF violations:
 New entity type for offending functional dependency

Example
Fix2NF
AB DF {B, C}  A
A
B
AC {B, C}  D
B (FK) (AK1.1) AD {B, C}  F
C (AK1.2) E
D AF
F
Fix3NF
D
F
Third Normal Form

 Requirements for Third Normal Form (3NF):


 Table must be in Second Normal Form
 Non-prime attributes must be non-transitively dependent on every superkey
 or: No dependency of non-key attribute on attribute(s) that is/are not a key
 Fixing 3NF violations:
 New entity type for offending functional dependency
 Original entity type:
 Remove dependent attributes
 Determinant implements relationship
Example
Fix2NF
AB DF {B, C}  A
A
B
AC {B, C}  D
B (FK) (AK1.1) AD {B, C}  F
C (AK1.2) E
D (FK) AF
Fix3NF
D
F
Finding functional dependencies, part 4

 Possible violations of Third Normal Form:


 Dependency of a non-key attribute on a non-key attribute
 Dependency of a non-key attribute on a combination of attributes
 Not subset of any candidate key
 Not superset of any candidate key

 Testing for:
 Dependency of any attribute on a non-key attribute
 Can be skipped for tables with no non-key attributes
 Dependency of any attribute on a combination of attributes
 Can be skipped for tables with:
 No composite keys and ≤1 non-key attribute
 One composite key and no non-key attributes
Finding functional dependencies, part 4

 Dependencies on a single non-key attribute


 Pattern to be populated:
 One non-key column equal
 All other columns different
 Valid example with required pattern found or created?
 No dependencies on non-key column being tested
 Impossible to create valid example with the required pattern?
 One or more other columns depend on column being tested
 But which one(s)?

Column A Column B Column C Column D Column E Column F Column G


a1 b1 c1 d1 e1 f1 g1
a2 b2 c2 d1 e2 f2 g2
Finding functional dependencies, part 4

 Dependencies on a single non-key attribute


 Impossible to create valid example with the required pattern?
 One or more other columns depend on column being tested
 But which one(s)?
 Check which other columns depend on column being tested
 Listen to reason for rejecting example
 Or test, one possibly dependent column at a time

Column A Column B Column C Column D Column E Column F Column G


a1 b1
? c1
? d1 e1
? f1
? g1
?
a2 b2
? c2
? d1 e2
? f2
? g2
?
Finding functional dependencies, part 4

 Dependencies on a single non-key attribute


 Impossible to create valid example with the required pattern?
 One or more other columns depend on column being tested
 But which one(s)?
 Check which other columns depend on column being tested
 Listen to reason for rejecting example
 Or test, one possibly dependent column at a time

Column A Column B Column C Column D Column E Column F Column G


? b1 ? d1 ? ? ?
? b2 ? d1 ? ? ?
Finding functional dependencies, part 4

 Dependencies on a single non-key attribute


 Impossible to create valid example with the required pattern?
 One or more other columns depend on column being tested
 But which one(s)?
 Check which other columns depend on column being tested
 Listen to reason for rejecting example
 Or test, one possibly dependent column at a time

Column A Column B Column C Column D Column E Column F Column G


? ? c1 d1 ? ? ?
? ? c2 d1 ? ? ?
Finding functional dependencies, part 4

 Dependencies on a single non-key attribute


 Impossible to create valid example with the required pattern?
 One or more other columns depend on column being tested
 But which one(s)?
 Check which other columns depend on column being tested
 Listen to reason for rejecting example
 Or test, one possibly dependent column at a time

Column A Column B Column C Column D Column E Column F Column G


? ? ? d1 e1 ? ?
? ? ? d1 e2 ? ?
Finding functional dependencies, part 4

 Dependencies on a single non-key attribute


 Impossible to create valid example with the required pattern?
 One or more other columns depend on column being tested
 But which one(s)?
 Check which other columns depend on column being tested
 Listen to reason for rejecting example
 Or test, one possibly dependent column at a time
 When rejected, that column depends on column being tested
 (Usually)
 Make sure to find all dependent columns!
 For each dependency: “normal” functional dependency, or derivation rule?

Column A Column B Column C Column D Column E Column F Column G


? ? ? d1 ? ? g1
? ? ? d1 ? ? g2
Finding functional dependencies, part 4

 Dependencies on a single non-key attribute


 Impossible to create valid example with the required pattern?
 “Normal” (not derived) dependencies of non-key column  violates 3NF
 Create new entity type
 Remove dependent attribute(s)
Fix3NF Example
D A
B (AK1.1)
E
G C (AK1.2)
D (FK)
E (AK2.1)
F
Functional dependencies found: DE F (AK2.1)
G
DG

Column A Column B Column C Column D Column E Column F Column G


Finding functional dependencies, part 4

 Dependencies on a single non-key attribute


 Impossible to create valid example with the required pattern?
 Derived dependencies / dependent key columns
 No schema change needed
 Make note for later use
 Exclude dependent column from rest of test Example
 But do check for transitive dependencies if new dependency on
determinant is found! A
B (AK1.1)

C (AK1.2)
D
E
Functional dependencies found: DE F (AK2.1)
G
DG

Column A Column B Column C Column D Column E Column F Column G


Finding functional dependencies, part 4

 Dependencies on a single non-key attribute


 When tests for a column are completed:
 First fix model (if needed)
 Then continue with next column
 Repeat until all columns verified

Column A Column B Column C Column D Column E Column F Column G


Finding functional dependencies, part 4

 Dependencies on combination of attributes that are not a key


 Test possible combinations of two columns, then three, …
 Combination of several non-key columns

Column A Column B Column C Column D Column E Column F Column G


Finding functional dependencies, part 4

 Dependencies on combination of attributes that are not a key


 Test possible combinations of two columns, then three, …
 Combination of several non-key columns
 Combination of non-key column(s) with subset of a candidate key

Column A Column B Column C Column D Column E Column F Column G


Finding functional dependencies, part 4

 Dependencies on combination of attributes that are not a key


 Test possible combinations of two columns, then three, …
 Combination of several non-key columns
 Combination of non-key column(s) with subset of a candidate key
 Combination of several subsets of different candidate keys
 Problem: This results in a LOT of test cases!
 Solution: use your experience to avoid “silly” tests
 But remember that this involves assumptions!
Not a subset of a candidate key

Not a superset of a candidate key

Column A Column B Column C Column D Column E Column F Column G


Demo: dependencies on non-key attributes Player
Player name is of /
P p lays in
Date of birth
League code (FK)

p lays in / p lays in /
is played by is played by

Co mp e tition Match
League
Date (AK1.1)
Player 1 (FK) League code

Player 2 (FK) (AK1.2)


Frames won player 1
Frames won player 2
Highest break player 1
Highest break player 2 Co mp e tition Frame
Competition points player 1 c ontains /
Competition points player 2 is p art of P Date (FK)
Player 1 (FK)
Frame #

Player 1 score
Player 2 score

Currently checking

Date Player 1 Player 2 Frames 1 Frames 2 HB 1 HB 2 Points 1 Points 2

a1 b1 c1 d1 e1 f1 g1 h1 j1

a2 b2 c2 d1 e2 f2 g2 h2 j2
Demo: dependencies on non-key attributes Player
Player name is of /
P p lays in
Date of birth
League code (FK)

p lays in / p lays in /
is played by is played by

Co mp e tition Match
League
Date (AK1.1)
Player 1 (FK) League code

Player 2 (FK) (AK1.2)


Frames won player 1
Frames won player 2
Highest break player 1
Highest break player 2 Co mp e tition Frame
Competition points player 1 c ontains /
Competition points player 2 is p art of P Date (FK)
Player 1 (FK)
Frame #

Player 1 score
Player 2 score

Currently checking

Date Player 1 Player 2 Frames 1


?
Frames 2 HB 1 HB 2
?
Points 1
?
Points 2

2012-10-03 Katie Jim 2 1 40 12 12 10

2013-02-15 Tony Jack 2 1 49 37 12 10


Demo: dependencies on non-key attributes Player
Player name is of /
P p lays in
Date of birth
League code (FK)

p lays in / p lays in /
is played by is played by

Co mp e tition Match
League
Date (AK1.1)
Player 1 (FK) League code

Player 2 (FK) (AK1.2)


Frames won player 1
Frames won player 2
Highest break player 1
Highest break player 2 Co mp e tition Frame
Competition points player 1 c ontains /
Competition points player 2 is p art of P Date (FK)
Player 1 (FK)
Frame #

Player 1 score
Player 2 score

Currently checking

Date Player 1 Player 2 Frames 1


?
Frames 2 HB 1 HB 2
?
Points 1
?
Points 2

2012-10-03 Katie Jim 2 1 40 12 12 10

2013-02-15 Tony Jack 2 0 49 37 18 0


Demo: dependencies on non-key attributes Player
Player name is of /
P p lays in
Date of birth
League code (FK)

p lays in / p lays in /
is played by is played by

Co mp e tition Match
League
Date (AK1.1)
Player 1 (FK) League code

Player 2 (FK) (AK1.2)


Frames won player 1
Frames won player 2
Highest break player 1
Highest break player 2 Co mp e tition Frame
Competition points player 1 c ontains /
Competition points player 2 is p art of P Date (FK)
Player 1 (FK)
Frame #

Player 1 score
Player 2 score

Currently checking

Date Player 1 Player 2 Frames 1


?
Frames 2 HB 1 HB 2
?
Points 1
?
Points 2

2012-10-03 Katie Jim 2 1 40 12 12 10

2013-02-15 Tony Jack 2 0 49 37 18 0


Demo: dependencies on non-key attributes Player
Player name is of /
P p lays in
Date of birth
League code (FK)
12 20
p lays in / p lays in /
is played by is played by

Co mp e tition Match
League
Date (AK1.1)
Player 1 (FK) League code

Player 2 (FK) (AK1.2)


Frames won player 1
Frames won player 2
Highest break player 1
Highest break player 2 Co mp e tition Frame
Competition points player 1 c ontains /
Competition points player 2 is p art of P Date (FK)
Player 1 (FK)
Frame #

Player 1 score
Player 2 score

Currently checking

Date Player 1 Player 2 Frames 1


?
Frames 2 HB 1 HB 2
?
Points 1
?
Points 2

2012-10-03 Katie Jim 2 1 40 12 12 10

2013-02-15 Tony Jack 2 3 49 37 18 0


Demo: dependencies on non-key attributes Player
Player name is of /
P p lays in
Date of birth
League code (FK)

p lays in / p lays in /
is played by is played by

Co mp e tition Match
League
Date (AK1.1)
Player 1 (FK) League code

Player 2 (FK) (AK1.2)


Frames won player 1
Frames won player 2
Highest break player 1
Highest break player 2 Co mp e tition Frame
Competition points player 1 c ontains /
Competition points player 2 is p art of P Date (FK)
Player 1 (FK)
Frame #

Player 1 score
Player 2 score

Currently checking

Date Player 1 Player 2 Frames 1


?
Frames 2 HB 1 HB 2
?
Points 1
?
Points 2

2012-10-03 Katie Jim 2 1 40 12 12 10

2013-02-15 Tony Jack 2 3 49 37 12 20


Demo: dependencies on non-key attributes Player
Player name is of /
P p lays in
Date of birth
Dependency found: League code (FK)

• Frames 1  Points 1 p lays in / p lays in /


is played by is played by

Co mp e tition Match
League
Date (AK1.1)
Functional dependency Player 1 (FK) League code

or derivation rule? Player 2 (FK) (AK1.2)


Frames won player 1
Frames won player 2
Highest break player 1
Highest break player 2 Co mp e tition Frame
Competition points player 1 c ontains /
Competition points player 2 is p art of P Date (FK)
Player 1 (FK)
Frame #

Player 1 score
Player 2 score

Currently checking

Date Player 1 Player 2 Frames 1 Frames 2 HB 1 HB 2



Points 1 Points 2
Demo: dependencies on non-key attributes Player
Player name is of /
P p lays in
Date of birth
Dependency found: League code (FK)

• Frames 1  Points 1 p lays in / p lays in /


is played by is played by

Co mp e tition Match
League
Date (AK1.1)
Player 1 (FK) League code
Functional dependency!
Player 2 (FK) (AK1.2)
Frames won player 1
Frames won player 2

Violates 3NF!
Highest break player 1
Highest break player 2 Co mp e tition Frame
Competition points player 1 c ontains /
Competition points player 2 is p art of P Date (FK)
Player 1 (FK)
Frame #

Player 1 score
Player 2 score

Currently checking

Date Player 1 Player 2 Frames 1 Frames 2 HB 1 HB 2



Points 1 Points 2
Demo: dependencies on non-key attributes Player
Player name is of /
P p lays in
Date of birth
Dependency found: League code (FK)

• Frames 1  Points 1 p lays in / p lays in /


is played by is played by

Co mp e tition Match
League
Date (AK1.1)
Player 1 (FK) League code
Functional dependency!
Player 2 (FK) (AK1.2)
Frames won player 1 (FK)
Frames won player 2 Co mp e tition Frame

Violates 3NF!
Highest break player 1 c ontains / Date (FK)
Highest break player 2 is p art of P Co mp e tition
Player 1 (FK)Frame
2
Competition points player 1 c ontains / Frame #
Competition points player 2 is p art of P Date (FK)
Player
Player 11 (FK)
score
is s cored in /
Frame
Player #2 score
scores
Player 1 score
Co mp e tition points player 1
Player 2 score
Frames won player 1

Currently checking Competition points player 1

Date Player 1 Player 2 Frames 1 Frames 2 HB 1 HB 2



Points 1 Points 2
Demo: dependencies on non-key attributes Player
Player name is of /
P p lays in
Date of birth
Dependency found: League code (FK)

• Frames 1  Points 1 p lays in / p lays in /


is played by is played by

Co mp e tition Match
League
Date (AK1.1)
Player 1 (FK) League code
Functional dependency!
Player 2 (FK) (AK1.2)
Frames won player 1 (FK)
Frames won player 2 Co mp e tition Frame
Highest break player 1 c ontains / Date (FK)
Highest break player 2 is p art of P Player 1 (FK)
Competition points player 2 Frame #

is s cored in / Player 1 score


scores Player 2 score

Co mp e tition points player 1


Frames won player 1

Currently checking Competition points player 1

Date Player 1 Player 2 Frames 1 Frames 2 HB 1 HB 2



Points 1 Points 2
Demo: dependencies on non-key attributes Player
Player name is of /
P p lays in
Date of birth
Dependency suspected: League code (FK)
12 20
• Frames 2  Points 2 p lays in / p lays in /
is played by is played by

Co mp e tition Match
League
Date (AK1.1)
Player 1 (FK) League code

Player 2 (FK) (AK1.2)


Frames won player 1 (FK)
Frames won player 2 Co mp e tition Frame
Highest break player 1 c ontains / Date (FK)
Highest break player 2 is p art of P Player 1 (FK)
Competition points player 2 Frame #

is s cored in / Player 1 score


scores Player 2 score

Co mp e tition points player 1


Frames won player 1

Currently checking
Competition points player 1

Date Player 1 Player 2 Frames 1 Frames 2 HB 1 HB 2 Points 2

2012-10-03 Katie Jim 2 1 40 12 10

2013-02-15 Tony Jack 2 3 49 37 0


Demo: dependencies on non-key attributes Player
Player name is of /
P p lays in
Date of birth
Dependency found: League code (FK)

• Frames 2  Points 2 p lays in / p lays in /


is played by is played by

Co mp e tition Match
League
Date (AK1.1)
Player 1 (FK) League code
Functional dependency!
Player 2 (FK) (AK1.2)
Frames won player 1 (FK)
Frames won player 2 Co mp e tition Frame

Violates 3NF!
Highest break player 1 c ontains / Date (FK)
Highest break player 2 is p art of P Player 1 (FK)
Competition points player 2 Frame #

is s cored in / Player 1 score


scores Player 2 score

Co mp e tition points player 1


Frames won player 1

Currently checking
Competition points player 1

Date Player 1 Player 2 Frames 1 Frames 2 HB 1 HB 2 Points 2


Demo: dependencies on non-key attributes Player
Player name is of /
P p lays in
Date of birth
Dependency found: League code (FK)
• Frames 2  Points 2 pplays
lays in
in // pplays
lays in
in //
is
is played
played by by is played
is played by by

Co mp e tition Match
League
Date (AK1.1)
League code
Functional dependency! Player 1 (FK)

Co mp e tition points player 2 Player 2 (FK) (AK1.2)


is s cored in / Frames won player 1 (FK)
Frames won player 2 scores Frames won player 2 (FK) Co mp e tition Frame
Highest break player 1 ccontains
ontains/ / Date (FK)
Competition points player 2
Highest break player 2 is
isppart
artof
of P Player 1 (FK)
Competition points player 2 Frame #

is s cored in / Player 1 score


scores Player 2 score

Co mp e tition points player 1


Frames won player 1

Currently checking
Competition points player 1

Date Player 1 Player 2 Frames 1 Frames 2 HB 1 HB 2 Points 2


Demo: dependencies on non-key attributes Player
Player name is of /
P p lays in
Date of birth
League code (FK)

p lays in / p lays in /
is played by is played by

Co mp e tition Match
League
Date (AK1.1)
Player 1 (FK) League code

Player 2 (FK) (AK1.2)


Frames won player 1 (FK)
Frames won player 2 (FK) Co mp e tition Frame
Highest break player 1 c ontains / Date (FK)
Highest break player 2 is p art of P
Player 1 (FK)
Frame #

is s cored in / is s cored in / Player 1 score


scores scores Player 2 score

Co mp e tition points
Frames won

Currently checking Competition points

?
Date
?
Player 1
?
Player 2
?
Frames 1 Frames 2
?
HB 1 HB 2
?
2012-10-03 Katie Jim 2 1 40 12

2013-02-15 Tony Jack 2 1 49 37


Demo: dependencies on non-key attributes Player
Player name is of /
P p lays in
Date of birth
League code (FK)

p lays in / p lays in /
is played by is played by

Co mp e tition Match
League
Date (AK1.1)
Player 1 (FK) League code

Player 2 (FK) (AK1.2)


Frames won player 1 (FK)
Frames won player 2 (FK) Co mp e tition Frame
Highest break player 1 c ontains / Date (FK)
Highest break player 2 is p art of P
Player 1 (FK)
Frame #

is s cored in / is s cored in / Player 1 score


scores scores Player 2 score

Co mp e tition points
Frames won

Currently checking Competition points

Date Player 1 Player 2


?
Frames 1 Frames 2 HB 1 HB 2

2012-10-03 Katie Jim 2 1 40 12

2013-02-15 Tony Jack 4 1 49 37


Demo: dependencies on non-key attributes Player
Player name is of /
P p lays in
Date of birth
League code (FK)

p lays in / p lays in /
is played by is played by

Co mp e tition Match
League
Date (AK1.1)
Player 1 (FK) League code

Player 2 (FK) (AK1.2)


Frames won player 1 (FK)
Frames won player 2 (FK) Co mp e tition Frame
Highest break player 1 c ontains / Date (FK)
Highest break player 2 is p art of P
Player 1 (FK)
Frame #

is s cored in / is s cored in / Player 1 score


scores scores Player 2 score

Co mp e tition points
Frames won

Currently checking Competition points

Date Player 1 Player 2 Frames 1 Frames 2 HB 1 HB 2


Demo: dependencies on non-key attributes Player
Player name is of /
P p lays in
Date of birth
League code (FK)

p lays in / p lays in /
is played by is played by

Co mp e tition Match
League
Date (AK1.1)
Player 1 (FK) League code

Player 2 (FK) (AK1.2)


Frames won player 1 (FK)
Frames won player 2 (FK) Co mp e tition Frame
Highest break player 1 c ontains / Date (FK)
Highest break player 2 is p art of P
Player 1 (FK)
Frame #

is s cored in / is s cored in / Player 1 score


scores scores Player 2 score

Co mp e tition points
Frames won

Currently checking Competition points

Date Player 1 Player 2 Frames 1 Frames 2 HB 1 HB 2


Demo: dependencies on non-key attributes Player
Player name is of /
P p lays in
Date of birth
League code (FK)

p lays in / p lays in /
is played by is played by

Co mp e tition Match
League
Date (AK1.1)
Player 1 (FK) League code

Player 2 (FK) (AK1.2)


Frames won player 1 (FK)
Frames won player 2 (FK) Co mp e tition Frame
Highest break player 1 c ontains / Date (FK)
Highest break player 2 is p art of P
Player 1 (FK)
Frame #

is s cored in / is s cored in / Player 1 score


scores scores Player 2 score

Co mp e tition points
Frames won

Do not check Competition points

Date Player 1 Player 2 Frames 1 Frames 2 HB 1 HB 2


Demo: dependencies on non-key attributes Player
Player name is of /
P p lays in
Date of birth
League code (FK)

p lays in / p lays in /
is played by is played by

Co mp e tition Match
League
Date (AK1.1)
Player 1 (FK) League code

Player 2 (FK) (AK1.2)


Frames won player 1 (FK)
Frames won player 2 (FK) Co mp e tition Frame
Highest break player 1 c ontains / Date (FK)
Highest break player 2 is p art of P
Player 1 (FK)
Frame #

is s cored in / is s cored in / Player 1 score


scores scores Player 2 score

Co mp e tition points
Frames won

Do not check Competition points

Date Player 1 Player 2 Frames 1 Frames 2 HB 1 HB 2


Demo: dependencies on non-key attributes Player
Player name is of /
P p lays in
Date of birth
League code (FK)

p lays in / p lays in /
is played by is played by

Co mp e tition Match
League
Date (AK1.1)
Player 1 (FK) League code

Player 2 (FK) (AK1.2)


Frames won player 1 (FK)
Frames won player 2 (FK) Co mp e tition Frame
Highest break player 1 c ontains / Date (FK)
Highest break player 2 is p art of P
Player 1 (FK)
Frame #

is s cored in / is s cored in / Player 1 score


scores scores Player 2 score

Co mp e tition points
Frames won

Currently checking Competition points

Date Player 1 Player 2 Frames 1 Frames 2 HB 1 HB 2


Demo: dependencies on non-key attributes Player
Player name is of /
P p lays in
Date of birth
League code (FK)

p lays in / p lays in /
is played by is played by

Co mp e tition Match
League
Date (AK1.1)
Player 1 (FK) League code

Player 2 (FK) (AK1.2)


Frames won player 1 (FK)
Frames won player 2 (FK) Co mp e tition Frame
Highest break player 1 c ontains / Date (FK)
Highest break player 2 is p art of P
Player 1 (FK)
Frame #

is s cored in / is s cored in / Player 1 score


scores scores Player 2 score

Co mp e tition points
Frames won

Currently checking Competition points

Date Player 1 Player 2 Frames 1 Frames 2 HB 1 HB 2


Demo: dependencies on non-key attributes Player
Player name is of /
P p lays in
Date of birth
League code (FK)

p lays in / p lays in /
is played by is played by

Co mp e tition Match
League
Date (AK1.1)
Player 1 (FK) League code

Player 2 (FK) (AK1.2)


Frames won player 1 (FK)
Frames won player 2 (FK) Co mp e tition Frame
Highest break player 1 c ontains / Date (FK)
Highest break player 2 is p art of P
Player 1 (FK)
Frame #

is s cored in / is s cored in / Player 1 score


scores scores Player 2 score

Co mp e tition points
Frames won

Currently checking Competition points

Date Player 1 Player 2 Frames 1 Frames 2 HB 1 HB 2


Demo: dependencies on non-key attributes Player
Player name is of /
P p lays in
Date of birth
League code (FK)

p lays in / p lays in /
is played by is played by

Co mp e tition Match
League
Date (AK1.1)
Player 1 (FK) League code

Player 2 (FK) (AK1.2)


Frames won player 1 (FK)
Frames won player 2 (FK) Co mp e tition Frame
Highest break player 1 c ontains / Date (FK)
Highest break player 2 is p art of P
Player 1 (FK)
Frame #

is s cored in / is s cored in / Player 1 score


scores scores Player 2 score

Co mp e tition points
Frames won

Currently checking Competition points

Date Player 1 Player 2 Frames 1 Frames 2 HB 1 HB 2


Demo: dependencies on non-key attributes Player
Player name is of /
P p lays in
Date of birth
League code (FK)

p lays in / p lays in /
is played by is played by

Co mp e tition Match
League
Date (AK1.1)
Player 1 (FK) League code

Player 2 (FK) (AK1.2)


Frames won player 1 (FK)
Frames won player 2 (FK) Co mp e tition Frame
Highest break player 1 c ontains / Date (FK)
Highest break player 2 is p art of P
Player 1 (FK)
Frame #

is s cored in / is s cored in / Player 1 score


scores scores Player 2 score

Co mp e tition points
Frames won

Currently checking Competition points

Date Player 1 Player 2 Frames 1 Frames 2 HB 1 HB 2

2012-10-03 Katie Jim 2 1 40 12

2013-02-07 Katie Jim 3 0 36 12


Demo: dependencies on non-key attributes Player
Player name is of /
P p lays in
Date of birth
League code (FK)

p lays in / p lays in /
is played by is played by

Co mp e tition Match
League
Date (AK1.1)
Player 1 (FK) League code

Player 2 (FK) (AK1.2)


Frames won player 1 (FK)
Frames won player 2 (FK) Co mp e tition Frame
Highest break player 1 c ontains / Date (FK)
Highest break player 2 is p art of P
Player 1 (FK)
Frame #

is s cored in / is s cored in / Player 1 score


scores scores Player 2 score

Co mp e tition points
Frames won

Currently checking Competition points

Date Player 1 Player 2 Frames 1 Frames 2 HB 1 HB 2

2012-10-03 Katie Jim 2 1 40 12

2013-02-15 Katie Jim 2 1 40 37


Demo: dependencies on non-key attributes Player
Player name is of /
P p lays in
Date of birth
League code (FK)

p lays in / p lays in /
is played by is played by

Co mp e tition Match
League
Date (AK1.1)
Player 1 (FK) League code

Player 2 (FK) (AK1.2)


Frames won player 1 (FK)
Frames won player 2 (FK) Co mp e tition Frame
Highest break player 1 c ontains / Date (FK)
Highest break player 2 is p art of P
Player 1 (FK)
Frame #

is s cored in / is s cored in / Player 1 score


scores scores Player 2 score

Co mp e tition points
Frames won

Currently checking Competition points

Date Player 1 Player 2 Frames 1 Frames 2 HB 1 HB 2

2012-10-03 Katie Jim 2 1 40 12

2013-02-15 Katie Jack 2 1 40 37


Demo: dependencies on non-key attributes Player
Player name is of /
P p lays in
Date of birth
League code (FK)

p lays in / p lays in /
is played by is played by

Co mp e tition Match
League
Date (AK1.1)
Player 1 (FK) League code

Player 2 (FK) (AK1.2)


Frames won player 1 (FK)
Frames won player 2 (FK) Co mp e tition Frame
Highest break player 1 c ontains / Date (FK)
Highest break player 2 is p art of P
Player 1 (FK)
Frame #

is s cored in / is s cored in / Player 1 score


scores scores Player 2 score

Co mp e tition points
Frames won

Currently checking Competition points

Date Player 1 Player 2 Frames 1


?
Frames 2 HB 1 HB 2

2012-10-03 Katie Jim 2 1 40 12

2013-02-15 Katie Jack 2 1 49 37


Demo: dependencies on non-key attributes Player
Player name is of /
P p lays in
Date of birth
Dependency found: League code (FK)
• {Player 1, Frames 1}  Frames 2 p lays in / p lays in /
is played by is played by

Co mp e tition Match
League
Date (AK1.1)
Actual underlying dependencies: Player 1 (FK) League code

• {League, Frames 1}  Frames 2 Player 2 (FK) (AK1.2)


Frames won player 1 (FK)
• Player 1  League Frames won player 2 (FK) Co mp e tition Frame
Highest break player 1 c ontains / Date (FK)
Highest break player 2 is p art of P
Player 1 (FK)
Frame #

is s cored in / is s cored in / Player 1 score


scores scores Player 2 score

Co mp e tition points
Frames won

Currently checking Competition points

Date Player 1 Player 2 Frames 1



Frames 2 HB 1 HB 2
Demo: dependencies on non-key attributes Player
Player name is of /
P p lays in
Date of birth
Dependency found: League code (FK)
• {Player 1, Frames 1}  Frames 2 p lays in / p lays in /
is played by is played by

Co mp e tition Match
League
Date (AK1.1)
Functional dependency Player 1 (FK) League code

or derivation rule? Player 2 (FK) (AK1.2)


Frames won player 1 (FK)
Frames won player 2 (FK) Co mp e tition Frame
Highest break player 1 c ontains / Date (FK)
Highest break player 2 is p art of P
Player 1 (FK)
Frame #

is s cored in / is s cored in / Player 1 score


scores scores Player 2 score

Co mp e tition points
Frames won

Currently checking Competition points

Date Player 1 Player 2 Frames 1



Frames 2 HB 1 HB 2
Demo: dependencies on non-key attributes Player
Player name is of /
P p lays in
Date of birth
Dependency found: League code (FK)
• {Player 1, Frames 1}  Frames 2 p lays in / p lays in /
is played by is played by

Co mp e tition Match
League
Date (AK1.1)
League code
Derivation rule! Player 1 (FK)
Player 2 (FK) (AK1.2)
Frames won player 1 (FK)
Frames won player 2 (FK) Co mp e tition Frame
Highest break player 1 c ontains / Date (FK)
Highest break player 2 is p art of P
Player 1 (FK)
Frame #

is s cored in / is s cored in / Player 1 score


scores scores Player 2 score

Co mp e tition points
Frames won

Currently checking Competition points

Date Player 1 Player 2 Frames 1



Frames 2 HB 1 HB 2
Demo: dependencies on non-key attributes Player
Player name is of /
P p lays in
Date of birth
Dependency found: League code (FK)
• {Player 1, Frames 1}  Frames 2 p lays in / p lays in /
is played by is played by

Co mp e tition Match
League
Date (AK1.1)
League code
Derivation rule! Player 1 (FK)
Player 2 (FK) (AK1.2)
Frames won player 1 (FK)
Frames won player 2 (FK) Co mp e tition Frame
Highest break player 1 c ontains / Date (FK)
Highest break player 2 is p art of P
Player 1 (FK)
Frame #

is s cored in / is s cored in / Player 1 score


scores scores Player 2 score

Co mp e tition points
Frames won

Currently checking Competition points


Derivation rule:
Frames won player 2
Date Player 1 Player 2 Frames 1 Frames 2 HB 1 HB 2 is computed from
Frames won player 1
and
Player 1  League code
(see specification in design docs)
Demo: dependencies on non-key attributes Player
Player name is of /
P p lays in
Date of birth
League code (FK)

p lays in / p lays in /
is played by is played by

Co mp e tition Match
League
Date (AK1.1)
Player 1 (FK) League code

Player 2 (FK) (AK1.2)


Frames won player 1 (FK)
Frames won player 2 (FK) Co mp e tition Frame
Highest break player 1 c ontains / Date (FK)
Highest break player 2 is p art of P
Player 1 (FK)
Frame #

is s cored in / is s cored in / Player 1 score


scores scores Player 2 score

Co mp e tition points
Frames won
Competition points

Derivation rule:
Frames won player 2
Date Player 1 Player 2 Frames 1 Frames 2 HB 1 HB 2 is computed from
Frames won player 1
and
Player 1  League code
(see specification in design docs)
Summary

 Problems
 Redundancy
 Modification anomalies
 Fixed by normalization

 Functional dependencies
The key, the
… whole key, and
… nothing but the key; so
… help me Codd
 Normal forms
 First Normal Form
 Second Normal Form
 Third Normal Form

Dr. E.J. Codd


Illustration: Michael J. Swart
References

 Further reading:
 Database normalization on Wikipedia:
http://en.wikipedia.org/wiki/Database_normalization
or
http://tinyurl.com/Norm-DB

 P.A. Bernstein’s algorithm for synthesis of a Third Normal Form schema:


http://student.bus.olemiss.edu/files/conlon/others/Others/Bus669_CompInf
o/DB_Design_SQL/Bernstein.pdf
or
http://tinyurl.com/BernAlgo

You might also like