Day 7 Normalization For Relational Databases
Day 7 Normalization For Relational Databases
Relational Databases
Physical Database
Build
Operational Database
CS 450 ERD Conventions
empnum
key
M 1
entity relationship
Participation Requirements
(optionality)
Terminology
CONCEPTUAL LOGICAL
(Business view) (Systems view)
ANALYSIS DESIGN
ENTITY TABLE
ATTRIBUTE COLUMN
■ Normalization:
■ The process of decomposing unsatisfactory "bad" relations by
breaking up their attributes into smaller relations
■
■ composite attributes multivalued attributes
■
Remedies
■ Create a separate field/table for each set of
related data.
Identify each set of related data with a primary
key
PART WAREHOUSE
(Primary Key) (Primary Key) QUANTITY
P0010 Warehouse A 400
MAIN POINT –
Eliminate redundant data in a table
Create separate tables for sets of values that apply to
multiple records
Table Violating 2NF
PART WAREHOUSE WAREHOUSE
(Primary Key) (Primary Key) QUANTITY ADDRESS
- Any field that does not relate to the primary key is placed in a separate table
(wherehouse address)
Tables Conforming to 2NF
PART_STOCK TABLE
PART (Primary Key) WAREHOUSE (Primary Key) QUANTITY
P0010 Warehouse A 400
P0010 Warehouse B 543
P0010 Warehouse C 329
P0020 Warehouse B 200
P0020 Warehouse D 278
WAREHOUSE TABLE
1
∞
WAREHOUSE (Primary Key) WAREHOUSE_ADDRESS
Warehouse A 1608 New Field Road
Warehouse B 4141 Greenway Drive
Warehouse C 171 Pine Lane
Warehouse D 800 Massey Street
Table Violating 2NF
EMPLOYEE_DEPARTMENT TABLE
EMPNO
FIRSTNAME LASTNAME WORKDEPT DEPTNAME
(Primary Key)
DEPARTMENT TABLE ∞
1
E11 Operations
Adv-
Student# Advisor# AdvisorFName AdvisorLName Class#
Room
1022 10 Susan Jones 412 101-07
Adv-
Student# Advisor# AdvisorFName AdvisorLName Class#
Room
1022 10 Susan Jones 412 101-07
Table: Registration
Table: Students
1022 143-01
4123 12 Anne Smith 216
1022 159-02
2011 10 Susan Jones 412
4123 201-01
4123 211-02
4123 214-01
•Tables Registration in 2NF
•Who about the Students?
Table: Registration
Table: Students
1022 143-01
4123 12 Anne Smith 216
1022 159-02
2011 10 Susan Jones 412
4123 201-01
4123 211-02
What is the candidate key for Students?
4123 214-01
Table: Registration
Student# Class#
1022 101-07
Table: Students
1022 143-01
Student# Advisor#
1022 159-02
Student# Class#
Table: Advisors
1022 101-07
Adv-
Advisor# AdvFirstName AdvLastName
Room
1022 143-01
10 Susan Jones 412
1022 159-02
4123 214-01
Student# Advisor#
1022 10
4123 12
2011 10
Table in First Normal Form
EmpID Project Time on Last First Dept Dept Name
Number Project Name Name Code
EN1-26 30-T3 25% Breen Sean TW Technical Writing
EmpID Dependent
458 Marge
458 Bart
458 Lisa
458 Maggie
Tables in Second Normal Form
Removed Repeated Data From Table
Step 2
EmpID FName LName ManagerID Dept Sector
285 Carl Carlson 2 Engineering 6G
365 Lenny 2 Marketing 8G
458 Homer Simpson 1 Safety 7G
Dependents Table
Department Table
EmpID Dependent
DeptCode Department Sector ManagerID
458 Marge EN Engineering 6G 2
458 Bart MK Marketing 8G 2
458 Lisa SF Safety 7G 1
458 Maggie
Mapping to schema with normalization
More Examples
Multivalued Attributes
Name
EMPLOYEE
• It is desirable to
Skill decompose multivalued
ID
attribute to a separate
entity. It might be a 1:N or
M:N relationship.
55
Mapping to
schema
Binary relationship
places has ONE
attribute ORDERDATE
then create placement
table and NO changes
in CUTOMER & ORDER
tables
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition.
May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
Mapping to schema
Mapping to schema
STUDENT register COURSE
STAFF
64
Weak Entities