Beruflich Dokumente
Kultur Dokumente
Lecture 8:
Data Modelling:
Converting ER Diagrams to Relational Tables
Introduction to Normalization
Learning Outcomes
Basic conversion rules;
The Optional-Max conversion process;
Introduce relational table normalisation.
Lecture 7
Null Values
Should be avoided.
Make it difficult to construct & interpret
relational data base queries.
Lecture 7
Teach
Course
CID [PK]
C_Name
Credits
Construct an ER
diagram and label the
upper and lower bounds
for relationship degree.
Enroll
All multi-valued
attributes should be
represented as entities.
Has
Students
SID [PK]
F_Name
L_name
Assigned
Stud_Maj
Home Address
H_Street
H_City
H_State
Major
Maj_ID [PK]
Description
Locker
LID [PK]
Building
Lecture 7
Course
CID [PK]
C_Name
Credits
Teach
Enroll
Has
Students
SID [PK]
F_Name
L_name
Assigned
Stud_Maj
Home Address
H_Street
H_City
H_State
Major
Maj_ID [PK]
Description
Locker
LID [PK]
Building
Course
CID [PK]
C_Name
Credits
Teach
Enroll
Faculty
Course
Students
Home_Address
Major
Locker
Has
Students
SID [PK]
F_Name
L_name
Assigned
Stud_Maj
Home Address
H_Street
H_City
H_State
Major
Maj_ID [PK]
Description
N
Locker
LID [PK]
Building
Lecture 7
Faculty
FID [PK]
F_Name
L_name
Course
CID [PK]
C_Name
Credits
Teach
Enroll
Students
SID [PK]
F_Name
L_name
Has
Assigned
Stud_Maj
Home
Address
Locker
LID [PK]
Building
Major
Maj_ID [PK]
Description
H_Street
H_City
H_State
Course
CID [PK]
C_Name
Credits
Teach
H_City
H_State
Enroll
Has
Students
SID [PK]
F_Name
L_name
Assigned
Stud_Maj
Major
Maj_ID [PK]
Description
N
Locker
LID [PK]
Building
Lecture 7
Faculty
FID [PK]
F_Name
L_name
Course
CID [PK]
C_Name
Credits
Teach
N
Enroll
Students
SID [PK]
F_Name
L_name
Has
Stud_Maj
N
Home Address
H_Street
H_City
H_State
11
Assigned
Major
Maj_ID [PK]
Description
Locker
LID [PK]
Building
Faculty
FID [PK]
F_Name
L_name
Course
CID [PK]
C_Name
Credits
Teach
N
Enroll
12
Students
SID [PK]
F_Name
L_name
Assigned
N
Stud_Maj
Home Address
H_Street
H_City
H_State
Major
Maj_ID [PK]
Description
N
Locker
LID [PK]
Building
Lecture 7
Faculty
FID [PK]
F_Name
L_name
concatenated
key
Course
CID [PK]
C_Name
Credits
Teach
C_Enroll
intersection
table
Enroll
Students
SID [PK]
F_Name
L_name
Has
Stud_Maj
Major
Maj_ID [PK]
Description
Home
Address
H_Street
H_City
H_State
13
Assigned
N
Locker
LID [PK]
Building
Faculty
FID [PK]
F_Name
L_name
Course
CID [PK]
C_Name
Credits
Teach
N
C_Enroll
Enroll
Has
14
Students
SID [PK]
F_Name
L_name
Stud_Maj
Home
Address
H_Street
H_City
H_State
Major
Maj_ID [PK]
Description
Assigned
N
N
Locker
LID [PK]
Building
Lecture 7
Construct ERD
Rule 2
Rule 3
Rule 4
Rule 5
Rule 6
Rule 7
Rule 8
Rule 9
15
Normalization
Normalization is a technique for producing a set of
relations with desirable properties, given the data
requirements of an enterprise.
The process of normalization is a formal method that
identifies relations based on their primary or candidate
keys and the functional dependencies among their
attributes.
16
Lecture 7
Normal forms
17
Normal forms
Unnormalized relation
Remove repeating
groups
1NF
Remove partial
dependencies
2NF
Remove transitive
dependencies
3NF
18
Lecture 7
Unnormalized form
WHNo WHLoc
ProductNo
ProductDesc
Price
PCode
CDesc
Qty
10
1001
Hammer
10.99
Hardware
06
1002
Screwdriver
03.99
Hardware
08
1010
Wood Drill
30.49
ET
Electrical
10
1001
Hammer
10.99
Hardware
01
4001
Stepladder
49.99
Hardware
02
Ilford
30
Exeter
19
WHLoc
ProductNo
ProductDesc
Price
PCode
CDesc
Qty
10
Ilford
1001
Hammer
10.99
Hardware
06
1002
Screwdriver
03.99
Hardware
08
1010
Wood Drill
30.49
ET
Electrical
10
1001
Hammer
10.99
Hardware
01
4001
Stepladder
49.99
Hardware
02
30
Exeter
Repeating Group
20
10
Lecture 7
WAREHOUSE(WHNo, WHLoc).
STOCK(WHNo, ProductNo, ProductDesc, Price, PCode,
CDesc, Qty).
21
WHLoc
10
Ilford
30
Exeter
Stock
WHNo
ProductNo
ProductDesc
Price
PCode
CDesc
Qty
10
1001
Hammer
10.99
Hardware
06
10
1002
Screwdriver
03.99
Hardware
08
10
1010
Wood Drill
30.49
ET
Electrical
10
30
1001
Hammer
10.99
Hardware
01
30
4001
Stepladder
49.99
Hardware
02
22
11
Lecture 7
Warehouse
WHNo
WHLoc
10
Ilford
30
Exeter
Stock
WHNo
ProductNo
ProductDesc
Price
PCode
CDesc
Qty
10
1001
Hammer
10.99
Hardware
06
10
1002
Screwdriver
03.99
Hardware
08
10
1010
Wood Drill
30.49
ET
Electrical
10
30
1001
Hammer
10.99
Hardware
01
30
4001
Stepladder
49.99
Hardware
02
23
Warehouse
WHNo
WHLoc
10
Ilford
30
Exeter
Stock
WHNo
ProductNo
ProductDesc
Price
PCode
CDesc
Qty
10
1001
Hammer
10.99
Hardware
06
10
1002
Screwdriver
03.99
Hardware
08
10
1010
Wood Drill
30.49
ET
Electrical
10
30
1001
Hammer
10.99
Hardware
01
30
4001
Stepladder
49.99
Hardware
02
24
12
Lecture 7
Editing
same price will be charged for
a product regardless of where
it is supplied from.
If price of hammers at
WHNo10 = 11.99, the price at
WHNo30 will still be = 10.99.
This will make the data
inconsistent.
Warehouse
WHNo
WHLoc
10
Ilford
30
Exeter
Stock
WHNo
ProductNo
ProductDesc
Price
PCode
CDesc
Qty
10
1001
Hammer
10.99
Hardware
06
10
1002
Screwdriver
03.99
Hardware
08
10
1010
Wood Drill
30.49
ET
Electrical
10
30
1001
Hammer
10.99
Hardware
01
30
4001
Stepladder
49.99
Hardware
02
25
WHNo
WHLoc
10
Ilford
30
Exeter
26
13
Lecture 7
ProductNo
ProductDesc
Price
PCode
CDesc
Qty
10
1001
Hammer
10.99
Hardware
06
10
1002
Screwdriver
03.99
Hardware
08
10
1010
Wood Drill
30.49
ET
Electrical
10
30
1001
Hammer
10.99
Hardware
01
30
4001
Stepladder
49.99
Hardware
02
27
Warehouse
WHNo
WHLoc
10
Ilford
30
Exeter
Stock
Product
WHNo
ProductNo
Qty
ProductNo
ProductDesc
Price
PCode
CDesc
10
1001
06
1001
Hammer
10.99
Hardware
10
1002
08
1002
Screwdriver
03.99
Hardware
10
1010
10
30
1001
01
1010
Wood Drill
30.49
ET
Electrical
30
4001
02
4001
Stepladder
49.99
Hardware
28
14
Lecture 7
Warehouse
WHNo
WHLoc
10
Ilford
30
Exeter
Stock
Product
WHNo
ProductNo
Qty
ProductNo
ProductDesc
Price
PCode
CDesc
10
1001
06
1001
Hammer
10.99
Hardware
10
1002
08
1002
Screwdriver
03.99
Hardware
10
1010
10
30
1001
01
1010
Wood Drill
30.49
ET
Electrical
30
4001
02
4001
Stepladder
49.99
Hardware
29
Warehouse
WHNo
WHLoc
10
Ilford
30
Exeter
Stock
Product
WHNo
ProductNo
Qty
ProductNo
ProductDesc
Price
PCode
CDesc
10
1001
06
1001
Hammer
10.99
Hardware
10
1002
08
1002
Screwdriver
03.99
Hardware
10
1010
10
30
1001
01
1010
Wood Drill
30.49
ET
Electrical
30
4001
02
4001
Stepladder
49.99
Hardware
30
15
Lecture 7
Warehouse
WHNo
WHLoc
10
Ilford
30
Exeter
Stock
Product
WHNo
ProductNo
Qty
ProductNo
ProductDesc
Price
PCode
CDesc
10
1001
06
1001
Hammer
10.99
Hardware
10
1002
08
1002
Screwdriver
03.99
Hardware
10
1010
10
30
1001
01
1010
Wood Drill
30.49
ET
Electrical
30
4001
02
4001
Stepladder
49.99
Hardware
31
Transitive dependencies
ProductNo
PCode
CDesc
32
16
Lecture 7
Stock
Warehouse
WHNo
WHLoc
10
Ilford
30
Exeter
Product
33
ProductNo
PDesc
Price
PCode
1001
Hammer
10.99
1002
Screwdriver
03.99
1010
Wood Drill
30.49
ET
4001
Stepladder
49.99
WHNo
ProductNo
Qty
10
1001
06
10
1002
08
10
1010
10
30
1001
01
30
4001
02
Product_Code
PCode
CDesc
Hardware
ET
Electrical
Summary Normalisation
Unnormalized relation
Remove repeating
groups
1NF
Remove partial
dependencies
2NF
Remove transitive
dependencies
3NF
34
17