+ All Categories
Home > Documents > Second Normal form For tutorial. Second Normal Form Remove part key dependencies –Only applies to...

Second Normal form For tutorial. Second Normal Form Remove part key dependencies –Only applies to...

Date post: 20-Dec-2015
Category:
View: 226 times
Download: 3 times
Share this document with a friend
28
Second Normal form For tutorial
Transcript
Page 1: Second Normal form For tutorial. Second Normal Form Remove part key dependencies –Only applies to forms that are in first normal form and have a compound.

Second Normal form

For tutorial

Page 2: Second Normal form For tutorial. Second Normal Form Remove part key dependencies –Only applies to forms that are in first normal form and have a compound.

Second Normal Form

• Remove part key dependencies– Only applies to forms that are in first normal

form and have a compound key• i.e. more than one field in the key.

– Remove the fields that are dependent on the part key and borrow the part key, to become the primary key of the new form. This form will then be a master form for the new form.

Page 3: Second Normal form For tutorial. Second Normal Form Remove part key dependencies –Only applies to forms that are in first normal form and have a compound.

TNF Exercise.

• Objective.– To practise the normalisation technique and to

produce a set of optimised relations from the normalisation of six documents.

• Method.– 1. Apply the rules of normalisation to the

supplied documents.– 2. Note the business rules.

Page 4: Second Normal form For tutorial. Second Normal Form Remove part key dependencies –Only applies to forms that are in first normal form and have a compound.

Supplied Documents

• Product Sales Report

• Wellingtons Invoice

• Product Stock Report

• Sales Executive report

• New Product / Amendment

• Customer Amendment

Page 5: Second Normal form For tutorial. Second Normal Form Remove part key dependencies –Only applies to forms that are in first normal form and have a compound.

Business Rules

• Product Code is not unique – each may have a number of pack sizes.

• Some Customers are allowed a discount. Each item has a Standard Price and up to 3 discount prices. A customer entitled to a discount has a single discount code A, B, C and will be charged the appropriate A, B or C price for all Products he orders.

• At any Warehouse, a Product is only stocked in one bin. The bin code may be considered unique to a warehouse.

• A customer deals with one, and only one, Sales Executive.

Page 6: Second Normal form For tutorial. Second Normal Form Remove part key dependencies –Only applies to forms that are in first normal form and have a compound.

Product W10190 DescriptionPack Size 10' Roll

Invoice Date Customer No. Name Quantity Line Value1468/02 2/2/2002 71698 Simons Health Hydro 2 € 12.601472/02 2/2/2002 32114 T White 3 € 18.901497/02 2/4/2002 10068 Int. Del. Limited 6 € 37.801501/02 2/9/2002 31724 Thumbscrew Ass. 3 € 18.901506/02 3/10/2002 21641 Hypo Explosives 15 € 94.50

PRODUCT SALES REPORT

Elastic Bandage

Product Sales Report

Page 7: Second Normal form For tutorial. Second Normal Form Remove part key dependencies –Only applies to forms that are in first normal form and have a compound.

Unnormalised Form

• Product Code + PackSize + ProductDescription + {InvoiceNumber + InvoiceDate + CustomerNumber + CustomerName + InvoiceQuantity + LineValue}

Page 8: Second Normal form For tutorial. Second Normal Form Remove part key dependencies –Only applies to forms that are in first normal form and have a compound.

First Normal Form

• ProductCode+PackSize + ProductDescription

• (ProductCode + PackSize)* + InvoiceNumber + InvoiceDate + CustomerNumber + CustomerName + InvoiceQuantity + LineValue

Page 9: Second Normal form For tutorial. Second Normal Form Remove part key dependencies –Only applies to forms that are in first normal form and have a compound.

First Normal form Product Sales Report

• The product description is dependent only on the ProductCode, so – ProductCode+PackSize + ProductDescription

• Becomes– ProductCode*+PackSize– ProductCode + ProductDescription

Page 10: Second Normal form For tutorial. Second Normal Form Remove part key dependencies –Only applies to forms that are in first normal form and have a compound.

2nf Product Sales Report

• and– (ProductCode + PackSize)* + InvoiceNumber +

InvoiceDate + CustomerNumber + CustomerName + InvoiceQuantity + LineValue

• becomes– (ProductCode + PackSize)* + InvoiceNumber* +

InvoiceQuantity + LineValue

• And– InvoiceNumber + InvoiceDate + CustomerNumber +

CustomerName

Page 11: Second Normal form For tutorial. Second Normal Form Remove part key dependencies –Only applies to forms that are in first normal form and have a compound.

Invoice DateCustomer No. Name

1468/02 02/02/2002 71698Simons Health Hydro

1472/02 02/02/2002 32114 T White

1497/02 02/04/2002 10068 Int. Del. Limited

1501/02 02/09/2002 31724 Thumbscrew Ass.1506/02 03/10/2002 21641 Hypo Explosives

2nd Normal form Product Sales Report

Product Pack SizeW10190 10' Roll

Product DescriptionW10190 1468/02

Product Pack Size Invoice QuantityLine Value

W10190 10' Roll 1468/02 2 € 12.60W10190 10' Roll 1472/02 3 € 18.90W10190 10' Roll 1497/02 6 € 37.80W10190 10' Roll 1501/02 3 € 18.90

Page 12: Second Normal form For tutorial. Second Normal Form Remove part key dependencies –Only applies to forms that are in first normal form and have a compound.

InvoiceInvoice Number 1468/02 Date 02/02/2002Customer 71698Name and Address Simon's Health Hydro

Warwick HouseBounds GreenLondon N11

Product DescriptionProduct Code

Pack Size

Standard Price

Discount Code

Discount Price Qty Line Value

Absorbant Gauze W10076 3x4 € 4.00 N € 4.00 15 € 60.00Zinc Oxide Plaster W10064 2" Roll € 12.40 N € 12.40 1 € 12.40Elastic Bandages W10190 10' Roll € 6.30 N € 6.30 2 € 12.60Soluble Aspirin W10941 500 € 10.00 N € 10.00 4 € 40.00Paracetamol W10918 250 € 9.20 N € 9.20 3 € 27.60

€ 152.60

INVOICE

Page 13: Second Normal form For tutorial. Second Normal Form Remove part key dependencies –Only applies to forms that are in first normal form and have a compound.

Unnormalised Form

• InvoiceNumber + InvoiceDate + CustomerNumber + CustomerName + CustomerInvoiceAddr + {ProductDescription + ProductCode + PackSize + StandardPrice + DiscountCode + DiscountPrice + InvoiceQuantity + LineValue} + InvoiceValue

Page 14: Second Normal form For tutorial. Second Normal Form Remove part key dependencies –Only applies to forms that are in first normal form and have a compound.

First Normal Form

• InvoiceNumber + InvoiceDate + CustomerNumber + CustomerName + CustomerInvoiceAddr + DiscountCode

• InvoiceNumber* + ProductCode + PackSize + ProductDescription + StandardPrice + DiscountPrice + InvoiceQuantity

Page 15: Second Normal form For tutorial. Second Normal Form Remove part key dependencies –Only applies to forms that are in first normal form and have a compound.

Second Normal Form

• InvoiceNumber + InvoiceDate + CustomerNumber + CustomerName + CustomerInvoiceAddr + DiscountCode

• InvoiceNumber* + ProductCode + PackSize + DiscountPrice + InvoiceQuantity

• ProductCode + ProductDescription

• ProductCode + PackSize + StandardPrice

Page 16: Second Normal form For tutorial. Second Normal Form Remove part key dependencies –Only applies to forms that are in first normal form and have a compound.

Product W10941Pack Size 500

Warehouse Stock Qty. Bin Code No. Ordered YTD1 930 71 2802 500 14 7643 1324 38 3204 2271 61 43625 0 94 31716 60 8 3207 0 6 48918 320 14 4016

Totals 5405 18124

PRODUCT STOCK REPORT

Product Stock Report

Page 17: Second Normal form For tutorial. Second Normal Form Remove part key dependencies –Only applies to forms that are in first normal form and have a compound.

Unnormalised Form

• ProductCode + PackSize + Warehouse + StockQuantity + BinCode + NoOrdYTD + StockQuantityTotal + NoOrdYTDTotal

Page 18: Second Normal form For tutorial. Second Normal Form Remove part key dependencies –Only applies to forms that are in first normal form and have a compound.

First Normal Form

• ProductCode + PackSize + StockQuantityTotal + NoOrdYTDTotal

• (ProductCode + PackSize)* + Warehouse + StockQuantity + BinCode + NoOrdYTD

Page 19: Second Normal form For tutorial. Second Normal Form Remove part key dependencies –Only applies to forms that are in first normal form and have a compound.

2nd Normal Form

• ProductCode + PackSize

• (ProductCode + PackSize)* + Warehouse + StockQuantity + BinCode + NoOrdYTD– remains the same

Page 20: Second Normal form For tutorial. Second Normal Form Remove part key dependencies –Only applies to forms that are in first normal form and have a compound.

Sales Executive 32

Customer Orders YTD Value OrdersDiscount

Code61784 110 € 560.00 A31477 212 € 1,028.00 A61344 104 € 442.00 A21242 38 € 271.00 B31687 73 € 340.00 B41279 30 € 128.00 B81311 21 € 90.00 C11600 87 € 1,008.00 N

Sales Executive Total 675 € 3,867.00

SALES EXECUTIVE REPORT

Sales Executive Report

Page 21: Second Normal form For tutorial. Second Normal Form Remove part key dependencies –Only applies to forms that are in first normal form and have a compound.

Unnormalised Form

• SalesExecutive + CustomerNumber + OrdersYTD + ValueOrders + DiscountCode + OrdersYTDTotal + ValueOrdersTotal

Page 22: Second Normal form For tutorial. Second Normal Form Remove part key dependencies –Only applies to forms that are in first normal form and have a compound.

First Normal Form

• SalesExecutive + OrdersYTDTotal + ValueOrdersTotal

• CustomerNumber + SalesExecutive* + OrdersYTD + ValueOrders + DiscountCode

• No compound keys, so no change for 2NF.

Page 23: Second Normal form For tutorial. Second Normal Form Remove part key dependencies –Only applies to forms that are in first normal form and have a compound.

*P_____

Product (W________) Description (________________________)

Pack Size (________) Prescription Indicator(_)

Unit Quantity (___) UK Drug Reg. No. (______)

Minimum Stock (_____) Discount Prices A ____.__B ____.__C ____.__

* Key 01 New Product02 Deletion03 Amendment

Product

Pack Size

NEW PRODUCT / AMENDMENT

Must be completed

New Product / Amendment

Page 24: Second Normal form For tutorial. Second Normal Form Remove part key dependencies –Only applies to forms that are in first normal form and have a compound.

Unnormalised Form

• ProductCode + PackSize + ProductDescription + PrescriptionIndicator + UnitQuantity + UKDrugRegNo + MinimumStock + DiscountCode + DiscountPrice

Page 25: Second Normal form For tutorial. Second Normal Form Remove part key dependencies –Only applies to forms that are in first normal form and have a compound.

First Normal Form

• ProductCode + PackSize + ProductDescription + PrescriptionIndicator + UnitQuantity + UKDrugRegNo + MinimumStock

• ProductCode + PackSize + DiscountCode + DiscountPrice

• Product Description, Prescription Indicator and UKDrugRegNo only depends on Product Code

Page 26: Second Normal form For tutorial. Second Normal Form Remove part key dependencies –Only applies to forms that are in first normal form and have a compound.

Second Normal Form

• ProductCode* + PackSize + UnitQuantity + MinimumStock

• ProductCode + ProductDescription + UKDrugRegNo + PrescriptionIndicator

• ProductCode + PackSize + DiscountCode + DiscountPrice

Page 27: Second Normal form For tutorial. Second Normal Form Remove part key dependencies –Only applies to forms that are in first normal form and have a compound.

Customer AmendmentCustomer No. (________)Sales Executive (____) (__)

Name (____________________)Address (____________________)

(____________________)(____________________)(____________________)

Credit Limit (______) Bulk Pack Only (_)

Discount Code (__)*

Licensed Drug Vendor (_)

(____________________)(____________________)(____________________)(____________________)

* A, B, C, Default N.

Delivery Address (if different from above)

Preferred Customer

CUSTOMER AMENDMENT

Page 28: Second Normal form For tutorial. Second Normal Form Remove part key dependencies –Only applies to forms that are in first normal form and have a compound.

Unnormalised Form

• CustomerNumber + SalesExecutive + PreferredCustomer + CustomerName + CustomerInvoiceAddr + CreditLimit + BulkPackOnly + DiscountCode + LicensedDrugVendor + CustomerDeliveryAddress


Recommended