Second Normal form For tutorial. Second Normal Form Remove part key dependencies –Only applies to...
-
date post
20-Dec-2015 -
Category
Documents
-
view
231 -
download
3
Transcript of 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 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.
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.
Supplied Documents
• Product Sales Report
• Wellingtons Invoice
• Product Stock Report
• Sales Executive report
• New Product / Amendment
• Customer Amendment
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.
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
Unnormalised Form
• Product Code + PackSize + ProductDescription + {InvoiceNumber + InvoiceDate + CustomerNumber + CustomerName + InvoiceQuantity + LineValue}
First Normal Form
• ProductCode+PackSize + ProductDescription
• (ProductCode + PackSize)* + InvoiceNumber + InvoiceDate + CustomerNumber + CustomerName + InvoiceQuantity + LineValue
First Normal form Product Sales Report
• The product description is dependent only on the ProductCode, so – ProductCode+PackSize + ProductDescription
• Becomes– ProductCode*+PackSize– ProductCode + ProductDescription
2nf Product Sales Report
• and– (ProductCode + PackSize)* + InvoiceNumber +
InvoiceDate + CustomerNumber + CustomerName + InvoiceQuantity + LineValue
• becomes– (ProductCode + PackSize)* + InvoiceNumber* +
InvoiceQuantity + LineValue
• And– InvoiceNumber + InvoiceDate + CustomerNumber +
CustomerName
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
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
Unnormalised Form
• InvoiceNumber + InvoiceDate + CustomerNumber + CustomerName + CustomerInvoiceAddr + {ProductDescription + ProductCode + PackSize + StandardPrice + DiscountCode + DiscountPrice + InvoiceQuantity + LineValue} + InvoiceValue
First Normal Form
• InvoiceNumber + InvoiceDate + CustomerNumber + CustomerName + CustomerInvoiceAddr + DiscountCode
• InvoiceNumber* + ProductCode + PackSize + ProductDescription + StandardPrice + DiscountPrice + InvoiceQuantity
Second Normal Form
• InvoiceNumber + InvoiceDate + CustomerNumber + CustomerName + CustomerInvoiceAddr + DiscountCode
• InvoiceNumber* + ProductCode + PackSize + DiscountPrice + InvoiceQuantity
• ProductCode + ProductDescription
• ProductCode + PackSize + StandardPrice
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
Unnormalised Form
• ProductCode + PackSize + Warehouse + StockQuantity + BinCode + NoOrdYTD + StockQuantityTotal + NoOrdYTDTotal
First Normal Form
• ProductCode + PackSize + StockQuantityTotal + NoOrdYTDTotal
• (ProductCode + PackSize)* + Warehouse + StockQuantity + BinCode + NoOrdYTD
2nd Normal Form
• ProductCode + PackSize
• (ProductCode + PackSize)* + Warehouse + StockQuantity + BinCode + NoOrdYTD– remains the same
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
Unnormalised Form
• SalesExecutive + CustomerNumber + OrdersYTD + ValueOrders + DiscountCode + OrdersYTDTotal + ValueOrdersTotal
First Normal Form
• SalesExecutive + OrdersYTDTotal + ValueOrdersTotal
• CustomerNumber + SalesExecutive* + OrdersYTD + ValueOrders + DiscountCode
• No compound keys, so no change for 2NF.
*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
Unnormalised Form
• ProductCode + PackSize + ProductDescription + PrescriptionIndicator + UnitQuantity + UKDrugRegNo + MinimumStock + DiscountCode + DiscountPrice
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
Second Normal Form
• ProductCode* + PackSize + UnitQuantity + MinimumStock
• ProductCode + ProductDescription + UKDrugRegNo + PrescriptionIndicator
• ProductCode + PackSize + DiscountCode + DiscountPrice
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
Unnormalised Form
• CustomerNumber + SalesExecutive + PreferredCustomer + CustomerName + CustomerInvoiceAddr + CreditLimit + BulkPackOnly + DiscountCode + LicensedDrugVendor + CustomerDeliveryAddress