You are on page 1of 12

1st Normal Form Problem

CustID CustName Phone

No repeating Groups 1 Fulton , Bruce 555-1222


Data Values are atomic 2 Jones, Bill 555-1313
Field names are unique
The relation has primary key CustID CustName Phone
The order of row doesn't matter 1 Fulton , Bruce 555-1222
1 Fulton , Bruce 555-1223
CUSTOMER 1 Fulton , Bruce 555-1224
CustomerID 2 Jones, Bill 555-1495
CustomerName
Phone
Products
Product Product Product CustID CustName Phone Product

Printer,
Fax,
Printer Fax Modem 1 Fulton , Bruce 555-1222 Modem
Fax 1 Jones, Bill 555-1223 Fax

Product
Printer
Fax Solution
Modem
Fax
2nd Normal Form

The relation is in first normal form


All attributes are dependent on the full primary key
No Non-key column is dependent on only a portion of primary key
Each non-key column is fully functional dependent on the primary key
Each attribute that is not in the primary key provides a fact that depends on the entire key

INVENTORY INVENTORY
PartID PartID WarehouseID Quantity
WareHouseID 1 1 5
Quantity 1 2 3
WareHouseAddress 2 1 2
3 1 2
4 2 4

Solution:

INVENTORY
PartID WarehouseID Quantity
1 1 5
1 2 3
2 1 2
3 1 2
4 2 4

Source: https://www.youtube.com/watch?v=zc7ucOoj0pg
Problem:

WarehouseAddress
Tucson
Phoenix
Tucson
Tucson
Phoenix

WAREHOUSE
WarehouseID WarehouseAddress
1 Tucson
2 Phoenix
1 Tucson
1 Tucson
2 Phoenix
ORDERS
OrderNum OrderDate ItemNum Description
51614 10/13/2015 FD11 Rocking Horse
51614 10/13/2015 NI27 Bobo Doll
51619 10/15/2015 FD11 Rocking Horse

SOLUTION:

ORDER
OrderNum OrderDate NumOrdered
51614 10/13/2015 1
51619 10/15/2015 2

ITEM
ItemNum Description
FD11 Rocking Horse
NI27 Bobo Doll
FD11 Rocking Horse

ORDER LINE
OrderNum ItemNum NumOrdered QuotedPrice
51614 FD11 1 124.95
51614 NI27 1 59.95
51619 FD11 2 124.95
NumOrdered QuotedPrice
1 124.95
1 59.95
2 124.95
3rd Normal Form

Relations with a single primary key are automatically in 2nd normal form
Relation in 2nd normal form may still have problems with redundancy
Relations are in third normal form when the relation is 2nd normal form
Each primary key provides a fact that is independent of other non-key attributes and depend only on the key
Each non-key attrbute is dependent on the primary key and only on the primary key. Non key
attributes are not derived and are not dependent on other non key attribute
All attributes are non-transitively dependent on the primary key
The only determinants are candidate keys(Boyce Codd Normal Form)

CUSTOMER Problem:
CustomeNum
CustomerName CUSTOMER
Balance CustomerNum
CreditLimit 126
RepNum 440
RepLname 502
RepFname
SOLUTION:

CUSTOMER
CustomerNum
126
440
502

CUSTOMER REPS
RepNum
15
45
15
s and depend only on the key
y key. Non key

CustomerName Balance CreditLimit RepNum RepLname RepFname


Toys Galore 1210 7500 15 Rafael Campos
GH Museum Store 345 5000 45 Tian Hui
Cards and More 5026 5000 15 Rafael Campos

CustomerName Balance CreditLimit RepNum


Toys Galore 1210 7500 15
GH Museum Store 345 5000 45
Cards and More 5026 5000 15

RepLname RepFname
Rafael Campos
Tian Hui
Rafael Campos
EMPLOYEE Problem:
EmpID
EmpFname EMPLOYEE
EmpLname EmpID EmpFname EmpLname DeptNo
DeptNo 101 Bruce Fulton D1
DeptName 102 Fred Rogers D2
103 Roger Hammerstein D1

EMPLOYEE
EmpID EmpFname EmpLname
101 Bruce Fulton
102 Fred Rogers
103 Roger Hammerstein

EMPLOYEE-DEPARTMENT
EmpID DeptNo
101 D1
102 D2
103 D1
DeptName
Finance
Manufacturing
Finance

DEPARTMENT
DeptNo DeptName
D1 Finance
D2 Manufacturing
A relation is in Fourth Normal Form when it is in third normal form
No instance contains two or more independent multivalued facts about an entity
There are no multivalued dependencies

Multivalues Dependencies occur when the relation is trying to represent more


than one to many relationships
EMPLOYEE SKILL LANGUAGE
EMPLOYEE SKILL LANGUAGE EmpID SkillCode
EmpID 101 1
SkillCode 101 1
LangCode 101 1
{Skill Proficiency} 101 2
{LangProficiency} 101 2
101 2
Other Examples 101 2
101 3
Student - Course - Teachers 101 3
Supplier - Products - Locations 101 3
101 2
102 2
102 2

Split in to two junction table

EMPLOYEE-SKILLS
EmpID SkillCode
101 1
101 1
101 1
102 2

EMPLOYEE-LANGUAGE
EmpID LangCode
101 1
101 2
101 3
102 1
102 2
LANGUAGE
LangCode SkillProficiency LangProficiency
1 Archery French
2 Archery German
3 Archery Chinese
1 Badminton French
2 Badminton German
3 Badminton Chinese
1 Darts French
2 Darts German
3 Darts Chinese
1 Badminton French
2 Badminton German
1 Badminton French
2 Badminton German

SkillProficiency
Archery
Badminton
Darts
Badminton

LangProficiency
French
German
Chinese
French
German

You might also like