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

SQLTrainingOnline DatabaseNormalization

The document describes a customer order table for a sporting goods company that sells baseball, basketball, and golf equipment. The table is not currently normalized and contains repeating customer information. It also lists the column definitions. The table violates 1st normal form by containing repeating groups of values and non-atomic data types in some columns.

Uploaded by

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

SQLTrainingOnline DatabaseNormalization

The document describes a customer order table for a sporting goods company that sells baseball, basketball, and golf equipment. The table is not currently normalized and contains repeating customer information. It also lists the column definitions. The table violates 1st normal form by containing repeating groups of values and non-atomic data types in some columns.

Uploaded by

Nain
Copyright
© © All Rights Reserved
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
You are on page 1/ 27

Sporting Goods Company

Selling Baseball, Basketball, and Golf Equipment

Current Customer Order Table -- Not Normalized

Customer Customer
Customer Email Mail Mail
Customer Customer Address Subscriptions Catalogs 1 Catalogs 2
123 Broadway Dr;
Bob Smith [email protected] Baseball, Basketball Basketball Golf
123 Broadway Dr;
Bob Smith [email protected] Baseball, Basketball Basketball Golf
123 Broadway Dr;
Bob Smith [email protected] Baseball, Basketball Basketball Golf
12 Kellogg Ave;
Jill Thomas [email protected] Baseball Baseball
12 Kellogg Ave;
Jill Thomas [email protected] Baseball Baseball
5 Maple Street;
Bob Smith [email protected] Golf Golf Baseball
5 Maple Street;
Bob Smith [email protected] Golf Golf Baseball

Column Definitions
Column Description
Customer Name of the customer that purchased the product. **Be careful, it is n
Customer Address Contains the Physical Home Address and the Email Address of the custo
Customer Email Subscriptions If the Customer is subscripted to an email list, it will be in this column.
Customer Mail Catalogs 1 If the customer wants a catalog at home, this contains the first catalog s
Customer Mail Catalogs 1 If the customer wants a catalog at home, this contains the second catalo
Product This is the product that was purchased by the customer. **Be careful, i
Product Manufacturer The manufacture of the product that was purchased.
Product Manufacturer Address The address of the manufacturer.
Product Details Extra details about the purchased product. The is one product detail pe
Product Cost The cost/price of the product. In this example, the cost does not chang
Quantity The number of items of a product purchased.
Total Line Amount The Product Cost multiplied by the Quantity
Order Date The date the whole order was placed. We are assuming a customer can
Order Total A sum of all of the total line amounts for an order.
Product Total
Product Manufacturer Product Product Line Order
Product Manufacturer Address Details Cost Quantity Amount Order Date Total
1 Spaulding
Basketball Spaulding Drive 29.5 Inch $25 1 $25 8/9/2018 $70
Louisville 345 Slugger
Bat Slugger Avenue 33 Inch $35 1 $35 8/9/2018 $70
1 Spaulding
Basketball Spaulding Drive 29.5 Inch $23 1 $23 8/12/2018 $23
23 Rawlings
Softball Rawlings Court 4 Pack $6 2 $12 8/10/2018 $57
23 Rawlings
Bat Rawlings Court 32 Inch $45 1 $45 8/10/2018 $57
1234 Titleist
Golf Balls Titleist Road 1 Dozen $44 2 $88 8/12/2018 $88
1234 Titleist
Basketball Titleist Road 1 Dozen $44 2 $88 8/12/2018 $88

ed the product. **Be careful, it is not unique.


and the Email Address of the customer. They can only have 1 email and 1 home address.
email list, it will be in this column. There can be multiple subscriptions.
ome, this contains the first catalog subscription.
ome, this contains the second catalog subscription.
ed by the customer. **Be careful, it is not unique.
t was purchased.

oduct. The is one product detail per product.


s example, the cost does not change for different purchases.

d. We are assuming a customer can only order 1 time per day, but they can have multiple products.
s for an order.
Customer Customer
Customer Email Mail Mail
Customer Customer Address Subscriptions Catalogs 1 Catalogs 2 Product
123 Broadway Dr;
Bob Smith [email protected] Baseball, Basketball Basketball Golf Basketball
123 Broadway Dr;
Bob Smith [email protected] Baseball, Basketball Basketball Golf Bat
123 Broadway Dr;
Bob Smith [email protected] Baseball, Basketball Basketball Golf Basketball
12 Kellogg Ave;
Jill Thomas [email protected] Baseball Baseball Softball
12 Kellogg Ave;
Jill Thomas [email protected] Baseball Baseball Bat
5 Maple Street;
Bob Smith [email protected] Golf Golf Baseball Golf Balls
5 Maple Street;
Bob Smith [email protected] Golf Golf Baseball Basketball

1st Normal Form The information is stored in a relational table and each column contains
Atomic Values

2nd Normal Form The table is in first normal form and all the columns depend on the tabl
Composite Keys/Partial Dependence

3rd Normal Form The table is in second normal form and all of its columns are not transiti
Transitive Dependence

4th Normal Form The table is in third normal form and does not contain two or more ind
Multi-Valued Facts
Product Total
Product Manufacturer Product Product Line Order
Manufacturer Address Details Cost Quantity Amount Order Date Total
1 Spaulding
Spaulding Drive 29.5 Inch $25 1 $25 8/9/2018 $70
Louisville 345 Slugger
Slugger Avenue 33 Inch $35 1 $35 8/9/2018 $70
1 Spaulding
Spaulding Drive 29.5 Inch $23 1 $23 8/12/2018 $23
23 Rawlings
Rawlings Court 4 Pack $6 2 $12 8/10/2018 $57
23 Rawlings
Rawlings Court 32 Inch $45 1 $45 8/10/2018 $57
1234 Titleist
Titleist Road 1 Dozen $44 2 $88 8/12/2018 $88
1234 Titleist
Titleist Road 1 Dozen $44 2 $88 8/12/2018 $88

and each column contains atomic values, and there are not repeating groups of columns.

olumns depend on the table’s primary key.

its columns are not transitively dependent on the primary key

ot contain two or more independent multi-valued facts about an entity


1st Normal Form The information is stored in a relational table and each column contains atom
Atomic Values
Example #1:
Customer Customer Address
123 Broadway Dr;
Bob Smith [email protected]
12 Kellogg Ave;
Jill Thomas [email protected]
5 Maple Street;
Bill Smith [email protected]

Example #2:
Customer Email
Customer Subscriptions
Bob Smith Baseball, Basketball
Jill Thomas Baseball
Bill Smith Golf, Basketball

Example #3:
Customer
Customer Mail Catalogs Customer Mail Mail
Customer 1 Catalogs 2 Catalogs 3
Bob Smith Basketball Golf Baseball
Jill Thomas Baseball
Bill Smith Golf Baseball
h column contains atomic values, and there are not repeating groups of columns.
1st Normal Form The information is stored in a relational table and each column contains atom
Atomic Values
Example #1:
Customer Customer Address Customer
123 Broadway Dr;
Bob Smith [email protected] Bob Smith
12 Kellogg Ave;
Jill Thomas [email protected] Jill Thomas
5 Maple Street;
Bill Smith [email protected] Bill Smith

Example #2:
Customer Email
Customer Subscriptions Customer
Bob Smith Baseball, Basketball Bob Smith
Jill Thomas Baseball Bob Smith
Bill Smith Golf, Basketball Jill Thomas
Bill Smith
Example #3: Bill Smith

Customer
Customer Mail Catalogs Customer Mail Mail
Customer 1 Catalogs 2 Catalogs 3
Bob Smith Basketball Golf Baseball Customer
Jill Thomas Baseball Bob Smith
Bill Smith Golf Baseball Bob Smith
Bob Smith
Jill Thomas
Bill Smith
Bill Smith
h column contains atomic values, and there are not repeating groups of columns.

Customer Address Customer Email Address

123 Broadway Dr [email protected]

12 Kellogg Ave [email protected]

5 Maple Street [email protected]

Customer Email
Subscriptions
Baseball
Basketball
Baseball
Golf

Basketball

Customer Mail Catalogs


Basketball
Golf
Baseball
Baseball
Golf
Baseball
2nd Normal Form The table is in first normal form and all the columns depend on the table’s p
Composite Keys/Partial Dependence
Product
Customer Customer Address Product Manufacturer
Bob Smith 123 Broadway Dr Basketball Spaulding
Bob Smith 123 Broadway Dr Bat Louisville Slugger
Jill Thomas 12 Kellogg Ave Bat Louisville Slugger
Mark Smith 5 Maple Street Golf Balls Titleist
Mark Smith 5 Maple Street Basketball Titleist
and all the columns depend on the table’s primary key.

Quantity Order Date


1 8/9/2018
2 8/9/2018
1 8/10/2018
2 8/12/2018
2 8/12/2018
2nd Normal Form The table is in first normal form and all the columns depend on the table’s p
Composite Keys/Partial Dependence
Product
Customer Customer Address Product Manufacturer
Bob Smith 123 Broadway Dr Basketball Spaulding
Bob Smith 123 Broadway Dr Bat Louisville Slugger
Jill Thomas 12 Kellogg Ave Bat Louisville Slugger
Mark Smith 5 Maple Street Golf Balls Titleist
Mark Smith 5 Maple Street Basketball Spaulding

Customer Order
Foreign Key Foreign Key
Customer Product Order Date Quantity
Bob Smith Basketball 8/9/2018 1
Bob Smith Bat 8/9/2018 2
Jill Thomas Bat 8/10/2018 1
Mark Smith Golf Balls 8/12/2018 2
Mark Smith Basketball 8/12/2018 2

Customer Table Product Table


Primary Key Primary Key
Customer Customer Address Product
Bob Smith 123 Broadway Dr Basketball
Jill Thomas 12 Kellogg Ave Bat
Mark Smith 5 Maple Street Golf Balls
and all the columns depend on the table’s primary key.

Quantity Order Date


1 8/9/2018
2 8/9/2018
1 8/10/2018
2 8/12/2018
2 8/12/2018

Product Manufacturer
Spaulding
Louisville Slugger
Titleist
3rd Normal Form The table is in second normal form and all of its columns are not transitive
Transitive Dependence

Product
Manufacturer
Product Product Manufacturer Address Product Details
Basketball Spaulding 1 Spaulding Drive 29.5 Inch
Bat Rawlings 23 Rawlings Court 33 Inch
Softball Rawlings 23 Rawlings Court 4 Pack
Golf Balls Titleist 1234 Titleist Road 1 Dozen
and all of its columns are not transitively dependent on the primary key

Product Cost
$25
$35
$6
$44
3rd Normal Form The table is in second normal form and all of its columns are not transitive
Transitive Dependence

Product
Manufacturer
Product Product Manufacturer Address Product Details
Basketball Spaulding 1 Spaulding Drive 29.5 Inch
Bat Rawlings 23 Rawlings Court 33 Inch
Softball Rawlings 23 Rawlings Court 4 Pack
Golf Balls Titleist 1234 Titleist Road 1 Dozen

Product Manufacturer Table


Primary Key

Product Manufacturer
Spaulding
Rawlings
Titleist
Product Table
Primary Key Foreign Key
Product Product Manufacturer Product Details Product Cost
Basketball Spaulding 29.5 Inch $25
Bat Rawlings 33 Inch $35
Softball Rawlings 4 Pack $6
Golf Balls Titleist 1 Dozen $44
and all of its columns are not transitively dependent on the primary key

Product Cost
$25
$35
$6
$44

Manufacturer Table

Product Manufacturer
Address
1 Spaulding Drive
23 Rawlings Court
1234 Titleist Road
4th Normal Form The table is in third normal form and does not contain two or more indepen
Multi-Valued Facts
Customer Email
Customer Customer Address Customer Email Address Subscriptions
Bob Smith 123 Broadway Dr [email protected] Baseball, Basketball
Jill Thomas 12 Kellogg Ave [email protected] Baseball
Bill Smith 5 Maple Street [email protected] Golf
es not contain two or more independent multi-valued facts about an entity
4th Normal Form The table is in third normal form and does not contain two or more indepen
Multi-Valued Facts
Customer Email
Customer Customer Address Customer Email Address Subscriptions
Bob Smith 123 Broadway Dr [email protected] Baseball, Basketball
Jill Thomas 12 Kellogg Ave [email protected] Baseball
Bill Smith 5 Maple Street [email protected] Golf

Customer Email
Customer Customer Address Customer Email Address Subscriptions
Bob Smith 123 Broadway Dr [email protected] Baseball
Bob Smith 123 Broadway Dr [email protected] Basketball
Jill Thomas 12 Kellogg Ave [email protected] Baseball
Bill Smith 5 Maple Street [email protected] Golf

Primary Key
Customer Customer Address Customer Email Address
Bob Smith 123 Broadway Dr [email protected]
Jill Thomas 12 Kellogg Ave [email protected]
Bill Smith 5 Maple Street [email protected]
es not contain two or more independent multi-valued facts about an entity

**We have repeating customers in our customer table because of the


multi-valued Customer Email Subscriptions. This causes repeating
addresses. We don't want that, so we end up separating the
Customer Email Subscriptions to it's own table.

Foreign Key
Customer Customer Email Subscriptions
Bob Smith Baseball
Bob Smith Basketball
Jill Thomas Baseball
Bill Smith Golf
Not Normalized
Issues: Has issues with 1NF, 2NF, 3NF, and 4NF

Customer Customer
Customer Email Mail Mail
Customer Customer Address Subscriptions Catalogs 1 Catalogs 2 Product
123 Broadway Dr;
Bob Smith [email protected] Baseball, Basketball Basketball Golf Basketball
123 Broadway Dr;
Bob Smith [email protected] Baseball, Basketball Basketball Golf Bat
123 Broadway Dr;
Bob Smith [email protected] Baseball, Basketball Basketball Golf Basketball
12 Kellogg Ave;
Jill Thomas [email protected] Baseball Baseball Softball
12 Kellogg Ave;
Jill Thomas [email protected] Baseball Baseball Bat
5 Maple Street;
Bob Smith [email protected] Golf Golf Baseball Golf Balls
5 Maple Street;
Bob Smith [email protected] Golf Golf Baseball Basketball

Sporting Goods Company


Selling Baseball, Basketball, and Golf Equipment
Product Total
Product Manufacturer Product Product Line Order
Manufacturer Address Details Cost Quantity Amount Order Date Total
1 Spaulding
Spaulding Drive 29.5 Inch $25 1 $25 8/9/2018 $70
Louisville 345 Slugger
Slugger Avenue 33 Inch $35 1 $35 8/9/2018 $70
1 Spaulding
Spaulding Drive 29.5 Inch $23 1 $23 8/12/2018 $23
23 Rawlings
Rawlings Court 4 Pack $6 2 $12 8/10/2018 $57
23 Rawlings
Rawlings Court 32 Inch $45 1 $45 8/10/2018 $57
1234 Titleist
Titleist Road 1 Dozen $44 2 $88 8/12/2018 $88
1234 Titleist
Titleist Road 1 Dozen $44 2 $88 8/12/2018 $88
After Normalization
Satisfies 1NF, 2NF, 3NF, and 4NF.

Customer Order Lines


Product ID Customer Order ID Quantity
Basketball-SP 1 1
Bat-L 1 1
Basketball-SP 3 1
Softball-R 2 2
Bat-R 2 1
Golf Balls - T 4 2
Basketball - T 4 2

Products
Product Product
Product ID Product Manufacturer Product Details Cost

Basketball-SP Basketball Spaulding 29.5 Inch $25

Bat-L Bat Louisville Slugger 33 Inch $35


Basketball-SP Basketball Spaulding 29.5 Inch $23
Softball-R Softball Rawlings 4 Pack $6
Bat-R Bat Rawlings 32 Inch $45
Golf Balls - T Golf Balls Titleist 1 Dozen $44

Basketball - T Basketball Titleist 1 Dozen $44

Product Manufacturer

Product Manufacturer
Product Manufacturer Address
Spaulding 1 Spaulding Drive
Louisville Slugger 345 Slugger Avenue
Rawlings 23 Rawlings Court
Titleist 1234 Titleist Road
**Primary Keys in Yellow
**Foreign Keys in Orange

Customer Orders
Customer Order ID Customer ID Order Date Order Total
1 bsmith1 8/9/2018 $70
2 jthomas1 8/10/2018 $57
3 bsmith1 8/12/2018 $23
4 bsmith2 8/12/2018 $88

Customers

Customer ID Customer Customer Address Customer Email

bsmith1 Bob Smith 123 Broadway Dr [email protected]

jthomas1 Jill Thomas 12 Kellogg Ave [email protected]

bsmith2 Bob Smith 5 Maple Street [email protected]

Customer Email Subscriptions Customer Mail Catalogs


Customer Email
Customer ID Subscriptions Customer ID
bsmith1 Baseball bsmith1
bsmith1 Basketball bsmith1

jthomas1 Baseball jthomas1


bsmith2 Golf bsmith2
bsmith2
Mail Catalogs
Customer Mail
Catalogs
Basketball
Golf

Baseball
Golf
Baseball

You might also like