Documente Academic
Documente Profesional
Documente Cultură
Example Nuts and Bolts Hardware Co-operative Nuts and Bolts Hardware Co-operative (NBHC) is a hardware chain of several stores, each trading under its own business name. Part of the stock list from Southside Hardware, one of the NBHC stores, is shown in Figure 1 below. NBHC wants to keep track of the inventory in all the stores in the co-operative because the ordering of products from suppliers is done centrally. Through that the chain can achieve higher overall quantily discounts than can be achieved by individual stores.
NUTS AND BOLTS HARDWARE CO-OPERATIVE Store ID: M515 Store Name: Southside Hardware Part Part Supplier Supplier Name number description number 3241 Bolt 2 cm 34513 Acme Bolt Co. 3541 4325 5678 1478 4327 Bolt 5 cm Washer 30 cm Nut 8 cm Screw 40 mm Washer 40 cm 34513 57913 34513 00972 57913 Acme Bolt Co. Washer Co. Acme Bolt Co. Best Fasteners Washer Co. STOCK LIST
Supplier Address 45 Hay Street 45 Hay Street 7 Blacktown Road 45 Hay Street 281 Pilbara Way 7 Blacktown Rod
546 $0.70 567 $0.12 342 $0.17 1267 $0.09 165 $0.15 Total stock cost
Figure 1 Part of a stock list from Southside Hardware Business rules 1. The sample stock list for Southside Hardware is representative of all stores. 2. Each supplier supplies several parts, but each part is supplied by only one supplier and the company wants to maintain this policy in the future. 3. Each part may be held in more than one store, for example, part number 3241 is held in store M515 (see Figure 1) but it may also be held in store M516 and M517. 4. Qty on hand is for a particular part in a particular store. 5. The unit cost price for a particular part is the same across all stores because of the central ordering of parts. 6. Total stock cost is the sum of all total cost fields for each product. 7. Store ID is a unique identifier for a store, part number is unique for a given part and supplier number is unique for a given supplier.
Before we use the NBHC example to illustrate the normalization process, let us look at a summary of the steps you need to perform to transform an un-normalised relation into third normal form(3NF) (see Figure 2) Unnormalised Relation
(0NF)
Remove attributes which can be calculated or derived. Assign a primary key (PK). Remove repeating groups. First Normal Form (1 NF) Check composite keys only. All non-key attributes should be fully functionally dependent on the PK Move attributes which are functionally dependent on only a subset of the PK, into a new relation.
Check non-key attributes against each other (note that alternate keys are key attributes). Move attributes that are only transitive dependent on the PK, into a new relation. Third Normal Form (3 NF)
Figure 2 Steps required to achieve first, second and third normal forms.
STORE ( store ID, store name) PART ( store ID, part number, part description, supplier number, supplier name, supplier address, qty on hand, unit cost price)
These two relations are now in first normal form (1NF). Note that we already have encountered the repeating group concept in Chapter 3. The relational model prescribes that repeating groups are not permitted, that is, 1NF is and integral part of the relational model.
SECOND NORMAL FORM (2NF) Relations are in 2NF, if they are in 1NF and all non-key attributes are fully functionally dependent on the primary key. We only have to check composite keys all relations which have a single attribute primary key are automatically in 2 NF if they are in 1NF. 2NF activities for NBHC
1. Relations automatically in 2 NF
Recall from the normalization rules in Figure 2 that any 1NF relation without a composite primary key is automatically in 2 NF. Hence, the STORE relation is already in 2NF.
PART(store ID, part number, part description, supplier number, supplier name, supplier address, qty on hand, unit cost price)
THIRD NORMAL FORM (3NF) For 3NF you only investigate dependencies between non-key attributes-transitive dependency. Remember that alternate keys, if any, are key attributes by definition. In the NBHC problem there are no alternate keys. Transitive dependence is defined as: If attribute A is functionally dependent on another non-key attribute B, which is dependent on the primary key, then attribute A is said to be transitive dependent on the primary key, that is, dependent on the primary key through attribute B. 3NF activities for NBHC
STORED PART
(store ID, part number, qty on hand) (There are no non-key attribute dependencies here)
PART (part number, part description, supplier number, supplier name, supplier address, unit cost price)
Figure 4 Transitive dependencies for the NBHC problem Note that in each of STORE and STORED PART there is only one non-key attribute, that is, there is no possibility for transitive dependencies to occur. ;;;;;;; In PART, all non-key attributes are dependent on the primary key part number, but supplier name and supplier address are also dependent on supplier number. This means that these two attributes are transitive dependent (via supplier number) on the PK (part number). They need to be moved to a new relation. The revised set of relations, showing foreign keys as well, are shown in Figure 5. These relations are now in 3NF. STORE STORED PART PART SUPPLIER (store ID, store name) (store ID, part number, qty on hand) (part number, part description, supplier number, unit cost price) (supplier number, supplier name, supplier address) Figure 5 3NF relations for the NBHC problem
5
Exercise 1: Using the following data, create an unnormalised relation, then normalize it to 1NF, 2NF and 3NF. Use the business rules, which you can infer from the data. If necessary, state any assumptions which you make.
ID# 202 296 328 419 790 987 1290 1333 5693 6785 6788 Supp code L02 SC1 C03 F11 L02 M01 AS1 L02 C03 T07 L02 Supplier Lincoln Schoettel Colchester Fluke Lincoln Mitutoyo Allstar Lincoln Colchester Tektronics Lincoln Description Welder 400 Amp Deepwater barge Lathe 1500 BC Multimeter Welder 400 Amp Micrometer Satcom 2000 Welder 300 Amp Lathe 1800 BC Oscilloscope Welder 400 Amp Dept ID FAB FEH MEC ELE FAB MEC PEH MEC MEC ELE PEH Department name Fabrication Shop P&E Hire Mechanical Shop Electrical Shop Fabrication Shop Mechanical Shop P&E Hire Mechanical Shop Mechanical Shop Electrical Shop P&E Shop Opening WDV $2760 $221000 $8750 $430 $2760 $440 $7200 $2440 $9900 $5700 $2760 Dep rate 20% 10% 10% 20% 20% 5% 30% 15% 10% 10% 20% Dep amt $552 $22100 $875 $86 $552 $22 $2160 $366 $990 $570 $552 Loc ID WE VI KW BE WE KW TH KW KW BE KW Location Welshpool Varanus Is. Kewdale Belmont Welshpool Kewdale Thailand Kewdale Kewdale Belmont Kwinana
Exercise 2: Using the following data, create an unnormalised relation, then normalize it to 1NF, 2NF and 3NF. Use the business rules which you can infer from the data. If necessary, state any assumptions which you make.
Duty code TR SR TR T T F F T MR MR F A/C ID 003 007 009 026 027 032 037 072 076 088 112 A/C type C130 UH-1 C130 A331B A331B F/A18 F/A18 A331B P3B P3B FA-18 Aircraft make Hercule s Iroquois Hercule s Macchi Macchi Hornet Hornet Macchi Orion Orion Hornet Service description Transport SAR Transport Trainer Trainer Fighter Fighter Trainer Mar. recon Mar. recon Fighter Man ID LO BE LO AM AM MD MD AM LO LO MD Manufacturer Lockheed Bell Lockheed AerMacchi AerMacchi McDonnellDouglass McDonnellDouglass AerMacchi Lockheed Lockheed McDonnellDouglas Ctry USA USA USA Italy Italy USA USA Italy USA USA USA Base ID RI PE RI PE PE AM AM PE ED ED AM Based at Richmond Pearce Richmond Pearce Pearce Amberley Amberley Pearce Edinburgh Edinburgh Amberley State NSW WA NSW WA WA Qld Qld WA SA SA Qld
Exercise 3:
Based on the following Sales Invoice Form, collect data from the form and normalise your relations into 3NF.
Sales Invoice
Invoice#:
Date:_____________
Customer name: ___________________________________________________ Customer address: __________________________________________________ Suburb: ____________ State: ________ Post Code: ________ Phone No: __________________ ProductNo ProductName Qty Price Total
Sales Total
Comments:
**Conditions applied for warranty services. See the back page for details.
Exercise 4:
Based on the following Batch Order Form, collect data from the form and normalise your relations into 3NF.
Batch Orders
Placed order In stock Informed customer Picked up
Suburb: ____________ State : ________ Post Code: ________ Phone no: ______________
ReOrder No
OrdDate
ProdNo
ProdName
SupplierNo
SupplierName
Qty
Arrived?
Exercise 5:
Given the following forms, Normalise the information into 3NF.
Form F15
Purchase Order
ACME TRADING COMPANY 29-34 ASHVALE ROAD, NORTH ADELAIDE S.A. 5000 Tel No: 8278 8888 Supplier No: 213 Supplier Name: Peter Toolings Co. Ltd. 2001-1 370 Main North Road,
must be
Date: 19/3/2001 Order No: 19-3This Purchase Order No. quoted on all Packing Packages, Bills of Lading,
and Correspondence.
Quantity Description 10 Metrinch Socket & combination Spanner Set Bosch 2 Speed Hammer Drill
Cost 650.00
PSB-400-2
500.00
100.00
Total: Deliver to: Goods received section Req. No.: 12345 Charge A/C No.: 4213-CJ Conditions 1. All invoices must be passed to above address. 2. Delivery Advice Notes must accompany goods. 3. For Further Conditions see overleaf To be delivered by: 10/3/2001
Form F14
Purchase Requisition
ACME TRADING COMPANY 29-34 ASHVALE ROAD, NORTH ADELAIDE S.A. 5000 Tel No: 8278 8888 Staff No: 1234 Staff Name: Jim Jones 12345 Department Name: Maintenance Section Quantity Description Preferred Supplier Part No. / Code No. 5214-276 Estimate d Cost 650.00 Date: 12/3/2001 Requsition No: (Office use) Per Unit Cost
10
Metrinch Socket & combination Spanner Set Bosch 2 Speed Hammer Drill
65.00
PSB-4002
500.00
100.00
Total: Deliver to: Advise the section when goods arrive Required by: 10/3/2001
1150.00
Charge A/C No.: 4213-CJ Conditions 1. All requisition must be approved by the head of the department 2. If no preferred supplier, the purchasing section will find a supplier based on the company purchasing policy. Approved By:
Section Head
10
Exercise 6:
Given the following forms, Normalise the information into 3NF. MailHome Company Ltd. Customer Order
18 First Street, Panorama S.A. 5041 Tel no: 8272 8000 Fax no: 8272 8001 Web site: www.mailhome.com.au
Order No: 2453162 Order Date: 15/3/2000 Sales Rep No: 15 Sales Rep Name: Jim Richardson Customer Name: Credit Card Type: VISA Mary Jones Card Holder Name: M. G. Jones Jackson Video Production Company Ltd. Card No: 4509 6512 7610 80A Hutt Street, Adelaide. S.A. 5000 Tel no: 2712 9843 Expiry Date: 30/9/2000 Comments: Requested all items to be packaged with the original cardboard boxes. Item No. 12000-27 12000-35 12000-51 Item Name Arcosteel 8 Piece Knife Block Set Pack and Roll Folding Cart Bordex 72 Bottle Wine Rack Qty Price Line Total 1 109.95 1 29.95 2 129.00 Total: 109.95 29.95 288.00 427.90
Exercise 7:
Cc nhn vin ca b phn IT dng form sau lu li vic ci t phn mm trn mi my tnh. Form ny c th c dng nh ngun thu thp d liu thit kt CSDL. Sinh vin hy dn ra cc quan h chun 3NF. Ghi r cch thc hin.
Computer Description: Compaq Small Form Factor Brand: Compaq Staff ID (Computer used by): 51398 Software Software id name Version Vendor CPU: P4
Serial No: 2145278 CPU Speed: 2.0 GHz Staff Name: Jim Moore
XP 2000
Microsoft CD Microsoft CD CD CD CD
04/04/2004 Jason B. 05/04/2004 Jason B. 07/04/2004 Steve M. 10/04/2004 Deb. H. 15/04/2004 Deb. H. 09/04/2004 Jason B. 15/04/2004 Steve M.
11
Exercise 8:
Cc nhn vin b phn IT dng mn hnh (screen) sau hin th cc cuc gi v cc hnh ng x l ca h. Mn hnh ny c th c dng nh ngun thu thp d liu thit kt CSDL. Sinh vin hy dn ra cc quan h chun 3NF. Ghi r cch thc hin..
Action Description: ____The Rational ClearCase client does not run due to license server problem Model: Evo N1000C Computer Description: Compaq Small Form Factor CPU : P4 Client name: John Smith Serial No : 2145278
Brand: Compaq Client No: _59 Work Group: HRD Display of Action History:
Action ID Action Description
IT Staff ID (Responded)
IT Staff name
Start Date
Start Time
End Date
End Time
Call ID
Action Status
Referred by Action ID
150 200
Change Regional setting in ClearCase Rejoin Domain and test client setting Reinstall Rational ClearCase and set new parameters
392 377
150
300
398
200
12
Exercise 9: T vn vin thu thp c form sau. Form ny c th c dng nh ngun d liu thit kt CSDL. Sinh vin hy dn ra cc quan h chun 3NF. Ghi r cch thc hin
Rooffy Real Estate Company Ltd. 1 Main Street, Adelaide 5000. Phone: 8200 8000 Tax: 8200 8001 Web site: www.rooffy.com.au
Property:
Property ID: (1/2/002345) Address: Unit 4, 28 Boothy street, Panorama 5041
Representative: Rep ID: 1001 Rep Name: Ryan Green OwnerID: 2451 Owner Name: Joe Harpas Owner Address: 15 King Street, Panorama 5041. Next Auction: Auction ID: 25/3/2000 - 5 Date: 25/3/2000 Time: 12:00 noon
Day Sat Sun Fri Sun Sat Date 4/3/2000 5/3/2000 10/3/2000 12/3/2000 18/3/2000 Begin Time 1:00pm 2:00pm 12:00pm 1:00pm 3:00pm End Time 1:45pm 2:45pm 12:45pm 1:45pm 3:45pm
Expected Price:
150,000 165,000
Home Phone No
8212 6723
Mobile Phone:
0414 383318 Sales Agent Ryan Green Mary Jordan John Joans Ryan Green Mary Jordan
Fax. No:
13