Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Database Design: Logical Model Design & Access DB Creation University of California, Berkeley School of Information Management and Systems SIMS 257: Database Management IS 257 – Fall 2004 2004.09.20 - SLIDE 1 Lecture Outline • Review – Database Design, Conceptual Model – Object-Oriented Modeling • Logical Design for the Diveshop database • Access Database Creation IS 257 – Fall 2004 2004.09.20 - SLIDE 2 Lecture Outline • Review – Database Design, Conceptual Model – Object-Oriented Modeling • Logical Design for the Diveshop database • Access Database Creation IS 257 – Fall 2004 2004.09.20 - SLIDE 3 Database Design Process Application 1 External Model Application 2 Application 3 Application 4 External Model External Model External Model Application 1 Conceptual requirements Application 2 Conceptual requirements Application 3 Conceptual requirements Conceptual Model Logical Model Internal Model Application 4 Conceptual requirements IS 257 – Fall 2004 2004.09.20 - SLIDE 4 Object-Oriented Modeling • Becoming increasingly important as – Object-Oriented and Object-Relational DBMS continue to proliferate – Databases become more complex and have more complex relationships than are easily captured in ER or EER diagrams • (Most UML examples based on McFadden, “Modern Database Management”, 5th edition) IS 257 – Fall 2004 2004.09.20 - SLIDE 5 DiveShop ER Diagram Customer No DiveCust 1 Destination Name Destination no Customer No ShipVia n Dest n 1 DiveOrds n 1 ShipVia ShipVia 1 Destination no Site No 1 n Site No BioSite Species No 1 Destination n Sites Order No n 1 1/n ShipWrck Order No DiveItem n Item No n Site No 1 Species No BioLife IS 257 – Fall 2004 1 DiveStok Item No 2004.09.20 - SLIDE 6 Entities • • • • • Customer Dive Order Line item Shipping information Dive Equipment Stock/Inventory • Dive Locations IS 257 – Fall 2004 • Dive Sites • Sea Life • Shipwrecks 2004.09.20 - SLIDE 7 What must be calculated? • Total price for equipment rental? • Total price for equipment sale? • Total price of an order? – Vacation price – Equipment (rental or sale) – Shipping IS 257 – Fall 2004 2004.09.20 - SLIDE 8 What is Missing?? • Not really an “enterprise-wide” database – No personnel • • • • Sales people Dive masters Boat captains and crew payroll – Local arrangements • Dive Boats • Hotels – Suppliers/Wholesalers for dive equipment • Orders for new/replacement equipment – No history (only current or last order) IS 257 – Fall 2004 2004.09.20 - SLIDE 9 Object-Oriented Modeling • Becoming increasingly important as – Object-Oriented and Object-Relational DBMS continue to proliferate – Databases become more complex and have more complex relationships than are easily captured in ER or EER diagrams • (Most UML examples based on McFadden, “Modern Database Management”, 5th edition) IS 257 – Fall 2004 2004.09.20 - SLIDE 10 Object Benefits • Encapsulate both data and behavior • Object-oriented modeling methods can be used for both database design and process design – Real-World applications have more than just the data in the database they also involve the processes, calculations, etc performed on that data to get real tasks done – OOM can be used for more challenging and complex problems IS 257 – Fall 2004 2004.09.20 - SLIDE 11 Unified Modeling Language (UML) • Combined three competing methods • Can be used for graphically depicting – Software designs and interaction – Database – Processes IS 257 – Fall 2004 2004.09.20 - SLIDE 12 CLASS • A class is a named description of a set of objects that share the same attributes, operations, relationships, and semantics. – An object is an instance of a class that encapsulates state and behavior. • These objects can represent real-world things or conceptual things. – An attribute is a named property of a class that describes a range of values that instances of that class might hold. – An operation is a named specification of a service that can be requested from any of a class's objects to affect behavior in some way or to return a value without affecting behavior IS 257 – Fall 2004 2004.09.20 - SLIDE 13 UML Relationships • An relationship is a connection between or among model elements. • The UML defines four basic kinds of relationships: – Association – Dependency – Generalization – Realization IS 257 – Fall 2004 2004.09.20 - SLIDE 14 UML Diagrams • The UML defines nine types of diagrams: – activity diagram – class diagram • Describes the data and some behavioral (operations) of a system – collaboration diagram – component diagram – deployment diagram – object diagram – sequence diagram – statechart diagram – use case diagram IS 257 – Fall 2004 2004.09.20 - SLIDE 15 Class Diagrams • A class diagram is a diagram that shows a set of classes, interfaces, and/or collaborations and the relationships among these elements. IS 257 – Fall 2004 2004.09.20 - SLIDE 16 UML Class Diagram DIVEORDS Order No Customer No Sale Date Shipvia PaymentMethod CCNumber No of People Depart Date Return Date Destination Vacation Cost CalcTotalInvoice() CalcEquipment() IS 257 – Fall 2004 Class Name List of Attributes List of operations 2004.09.20 - SLIDE 17 Object Diagrams 307:DIVORDS Order No = 307 Customer No = 1480 Sale Date = 9/1/99 Ship Via = UPS PaymentMethod = Visa CCNumber = 12345 678 90 CCExpDate = 1/1/01 No of People = 2 Depart Date = 11/8/00 Return Date = 11/15/00 Destination = Fiji Vacation Cost = 10000 IS 257 – Fall 2004 2004.09.20 - SLIDE 18 Differences from Entities in ER • Entities can be represented by Class diagrams • But Classes of objects also have additional operations associated with them IS 257 – Fall 2004 2004.09.20 - SLIDE 19 Operations • Three basic types for database – Constructor – Query – Update IS 257 – Fall 2004 2004.09.20 - SLIDE 20 Associations • An association is a relationship that describes a set of links between or among objects. • An association can have a name that describes the nature of this relationship. You can put a triangle next to this name to indicate the direction in which the name should be read. IS 257 – Fall 2004 2004.09.20 - SLIDE 21 Associations • An association contains an ordered list of association ends. – An association with exactly two association ends is called a binary association – An association with more than two ends is called an n-ary association. IS 257 – Fall 2004 2004.09.20 - SLIDE 22 Associations: Unary relationships * 0..1 Person 0..1 IS 257 – Fall 2004 Is-married-to manages Employee 0..1 manager 2004.09.20 - SLIDE 23 Associations: Binary Relationship Employee 0..1 Is-assigned Parking Place 0..1 One-to-one Product Line 1 contains * Product One-to-many Student * Registers-for * Course Many-to-many IS 257 – Fall 2004 2004.09.20 - SLIDE 24 Associations: Ternary Relationships Part * Vendor IS 257 – Fall 2004 * Supplies * Warehouse 2004.09.20 - SLIDE 25 Association Classes Registers-for Student * Course * Computer Account Registration _________________ ________________ acctID Term issues Password * 0..1 Grade ServerSpace ________________ CheckEligibility() IS 257 – Fall 2004 2004.09.20 - SLIDE 26 Derived Attributes, Associations, and Roles Course Student Course Offering _________ ____________ ____________ Scheduled-for name Registers-for crseCode term ssn * crseTitle * * 1 section dateOfBirth creditHrs time Derived /age location attribute * * /participant Derived role {age = currentDate – dateOfBirth} /Takes Derived association IS 257 – Fall 2004 2004.09.20 - SLIDE 27 Generalization Employee ____________ empName empNumber address dateHired ____________ printLabel() Hourly Employee _______________ HourlyRate _______________ computeWages() IS 257 – Fall 2004 Salaried Employee _______________ Annual Sal stockoption _______________ Contributepension() Consultant _______________ contractNumber billingRate _______________ computeFees() 2004.09.20 - SLIDE 28 Other Diagramming methods • SOM (Semantic Object Model) • Object Definition Language (ODL) – Not really diagramming • Access relationships display • Hybrids IS 257 – Fall 2004 2004.09.20 - SLIDE 29 Application of SOM to Diveshop DIVECUST Name Address Street City StateProvince ZIPPostalCode Country Phone FirstContact 1.1 1.1 1.1 1.1 1.1 1.1 1.1 1.1 1.1 DIVEORDS IS 257 – Fall 2004 1.N 2004.09.20 - SLIDE 30 DIVEORDS DIVEORDS OrderNo SaleDate DIVECUST id SHIPVIA DESTINATION DIVEITEM PaymentMethod CCNumber CCExpDate NoOfPeople DepartDate ReturnDate VacationCost IS 257 – Fall 2004 2004.09.20 - SLIDE 31 Lecture Outline • Review – Database Design, Conceptual Model – Object-Oriented Modeling • Logical Design for the Diveshop database • Access Database Creation IS 257 – Fall 2004 2004.09.20 - SLIDE 32 Database Design Process Application 1 External Model Application 2 Application 3 Application 4 External Model External Model External Model Application 1 Conceptual requirements Application 2 Conceptual requirements Application 3 Conceptual requirements Conceptual Model Logical Model Internal Model Application 4 Conceptual requirements IS 257 – Fall 2004 2004.09.20 - SLIDE 33 DiveShop ER Diagram Customer No DiveCust 1 Destination Name Destination no Customer No ShipVia n Dest n 1 DiveOrds n 1 ShipVia ShipVia 1 Destination no Site No 1 n Site No BioSite Species No 1 Destination n Sites Order No n 1 1/n ShipWrck Order No DiveItem n Item No n Site No 1 Species No BioLife IS 257 – Fall 2004 1 DiveStok Item No 2004.09.20 - SLIDE 34 Logical Design: Mapping to a Relational Model • Each entity in the ER Diagram becomes a relation. • A properly normalized ER diagram will indicate where intersection relations for many-to-many mappings are needed. • Relationships are indicated by common columns (or domains) in tables that are related. • We will examine the tables for the Diveshop derived from the ER diagram IS 257 – Fall 2004 2004.09.20 - SLIDE 35 Customer = DIVECUST Customer No Name Street City State/Prov Zip/Postal Code Country 1480 Louis Jazdzewski 2501 O'Connor New Orleans LA 60332 U.S.A. 1481 Barbara Wright 6344 W. Freeway San Francisco CA 95031 U.S.A. 1909 Stephen Bredenburg 559 N.E. 167 Indianapolis Place IN 46241 U.S.A. 1913 Phillip Davoust 123 First Street Berkeley CA 94704 U.S.A. 1969 David Burgett 320 Montgomery SeattleStreet WA 98105 U.S.A. 2001 Mary Rioux1701 Gateway Pueblo Blvd. #385 CO 81002 U.S.A. 2306 Kim Lopez 14134 Nottingham HonoluluLane HI 96826 U.S.A. 2589 Hiram Marley 7233 Mill Run SanDrive Francisco CA 94123 U.S.A. 3154 Tanya Kulesa 505 S. Flower, NewMail YorkStop NY 48943 10032 U.S.A. 3333 Charles Sekaron 110 East Park Miller Avenue,SD Box 8 57362 U.S.A. 3684 Lowell Lutz915 E. Fesler Dallas TX 75043 U.S.A. 4158 Keith Lucas56 South Euclid Chicago IL 60542 U.S.A. 4175 Karen Ng 2134 ElmhillKlamath Pike Falls OR 97603 U.S.A. 5510 Ken Soule 58 Sansome Aurora Street CO 89022 U.S.A. IS 257 – Fall 2004 Phone First Contact (902) 555-88881/29/95 (415) 555-43212/2/93 (317) 555-36441/5/93 (415) 555-91843/9/98 (206) 555-75803/12/99 (719) 555-20103/15/97 (808) 555-50501/29/99 (415) 555-64302/18/99 (212) 555-67501/30/99 (613) 555-43333/16/98 (214) 555-27222/15/99 (312) 555-43103/17/98 (503) 555-47003/20/99 (303) 555-66952/5/99 2004.09.20 - SLIDE 36 Dive Order = DIVEORDS Order No Customer No Sale Date 307 1480 9/1/99 310 1481 9/1/99 313 1909 9/1/99 314 1913 9/1/99 317 1969 9/1/99 320 2001 9/1/99 321 2306 9/1/99 325 2589 9/1/99 326 3333 9/1/99 327 3684 9/1/99 329 4158 9/1/99 330 4175 9/1/99 331 5510 9/1/99 333 5926 9/1/99 336 5719 9/1/99 IS 257 – Fall 2004 Ship Via UPS FedEx Walk In FedEx FedEx Walk In Emery Emery FedEx DHL Walk In FedEx FedEx DHL FedEx PaymentMethod CcNumber CcExpDateNo Of People Depart DateReturn DateDestinationVacationCost Visa 12345 678 90 1/1/01 2 11/8/00 11/15/00 Fiji 10000 Check 1 4/4/00 4/18/00 Santa Barbara 6000 Visa 456456456 9/11/00 4 6/27/00 7/11/00 Cozumel 8000 Check 3 2/7/00 2/14/00 Monterey 6000 AmEx 432432432 12/31/02 4 5/9/00 5/16/00 Fiji 20000 Cash 1 10/10/00 10/17/00 Santa Barbara 3000 Master Card 1112223334 8/12/00 1 3/15/00 4/12/00 New Jersey 8000 AmEx 332332332 12/10/99 1 3/15/00 4/12/00 New Jersey 8000 Money Order 2 2/10/00 2/17/00 Monterey 4000 Master Card 122122321 11/9/99 4 3/10/00 3/23/00 Florida 24000 Cash 1 5/4/00 5/15/00 Cozumel 1571 Check 2 7/3/00 7/10/00 Florida 6000 Money Order 6 6/20/00 6/30/00 Santa Barbara 36000 Discover 123123123 12/21/00 2 6/10/00 6/17/00 Fiji 10000 Cash 10 4/2/00 4/24/00 Great Barrier Reef 200000 2004.09.20 - SLIDE 37 Line item = DIVEITEM Order No Item No 307 90010 307 90020 307 90021 307 90030 307 90051 310 90011 310 90045 310 90059 310 90074 310 90078 313 90127 314 90072 314 90094 314 90100 317 90012 IS 257 – Fall 2004 Rental/SaleQty Rental Rental Rental Rental Rental Rental Rental Rental Rental Rental Sale Rental Rental Rental Sale Line Note 4 1 1 2 2 1 1 1 1 1 1 3 3 3 2 This is our most popular mask. These are our best selling fins. A good weight belt for beginners Holds 10 cubic feet of cargo. 2004.09.20 - SLIDE 38 Shipping information = SHIPVIA Ship Via DHL Emery FedEx UPS US Mail IS 257 – Fall 2004 Ship Cost 8 11 12 10 6 2004.09.20 - SLIDE 39 Dive Equipment Stock= DIVESTOK Item No 90010 90011 90012 90020 90021 90022 90023 90024 90025 90030 90031 90032 90033 90040 90041 90042 IS 257 – Fall 2004 DescriptionEquipment On Class Hand Reorder Point Cost Sale Price Rental Price Shotgun 2 Snorkel - Clear 12 2 $18.00 $30.00 $2.00 Shotgun 2 Snorkel - Red 12 2 $18.00 $30.00 $2.00 Shotgun 2 Snorkel - Teal 11 2 $18.00 $30.00 $2.00 Tri-Vent Mask Mask - Clear 14 2 $62.50 $100.00 $5.00 Tri-Vent Mask Mask - Red 10 2 $62.50 $100.00 $5.00 Tri-Vent Mask Mask - Teal 14 2 $62.50 $100.00 $7.00 Quad Vision Mask Mask - Clear 11 2 $48.25 $80.00 $7.00 Quad Vision Mask Mask - Red 13 2 $48.25 $80.00 $7.00 Quad Vision Mask Mask - Teal 10 2 $48.25 $80.00 $10.00 Sea Wing Fins Fins - Clear 12 2 $60.00 $100.00 $12.00 Sea Wing Fins Fins - Red 11 2 $60.00 $100.00 $12.00 Sea Wing Fins Fins - Teal 12 2 $60.00 $100.00 $12.00 Jet Fin - Black Fins 14 2 $30.00 $60.00 $10.00 D350 Second Regulator Stage 11 1 $162.50 $270.00 $20.00 G250 Second Regulator Stage 13 1 $144.50 $240.00 $20.00 G200 Second Regulator Stage 12 1 $105.25 $175.00 $20.00 2004.09.20 - SLIDE 40 Dive Locations = DEST DestinationDestination No Avg Name Temp Avg (F) Temp Spring (C) Temp Spring (F) Temp Summer (C) Temp Summer (F) Temp Fall Temp (C) (F) Fall Temp (C) Winter Temp Winter (F) Temp Accomodations (C) Night Life 1 Cozumel 78 25.556 76 24.444 84 28.889 78 25.556 74 23.333 Cheap Sleepy 2 Great Barrier Reef80 26.667 76 24.444 84 28.889 78 25.556 76 24.444 Moderate Pleasant 3 Monterey 60 15.556 62 16.667 64 17.778 64 17.778 58 14.444 Expensive Wild 4 Santa Barbara 75 23.889 73 22.777 78 25.556 72 22.222 70 21.111 Expensive Wild 5 Florida 77 25 75 23.889 85 29.444 78 25.556 70 21.111 Moderate Pleasant 6 Fiji 75 23.889 76 24.444 80 26.667 74 23.333 70 21.111 Expensive Sleepy 7 New Jersey 57 13.889 57 13.89 60 15.556 58 14.444 53 11.667 Expensive Pleasant IS 257 – Fall 2004 Body of Water Travel Cost Caribbean 1000 Coral Sea 5000 Pacific 2000 Pacific 3000 Caribbean 3000 South Pacific 5000 Atlantic 2000 2004.09.20 - SLIDE 41 Dive Sites = SITE Site No DestinationSite No Name Site HighlightSiteDistance NotesDistance from Depth Town from(m) (ft)Depth Town (km) (m) Visibility (ft)Visibility (m) Current 1001 1 Palancar Reef Reef 10 16.09 100 30.48 150 45.72 Strong 1002 1 Santa Rosa ReefReef 8 12.87 80 24.384 150 45.72 Strong 1003 1 Chancanab ReefR eef 4 6.437 60 18.288 100 30.48 Mild 1004 1 Punta Sur Reef 13 20.92 120 36.576 175 53.34 Strong 1005 1 Yocab Reef Reef 6 9.656 50 15.24 100 30.48 Mild 2001 2 Heron Island Reef 50 80.47 90 27.432 150 45.72 Mild 2002 2 Cod Hole Fish 45 72.42 50 15.24 150 45.72 Mild 2003 2 Butterfly Bay Caves 20 32.19 70 21.336 70 21.336 None 2004 2 Wheeler Reef Marine Life 30 48.28 50 15.24 125 38.1 Mild 2005 2 Watanabe Marine Life 130 209.2 150 45.72 200 60.96 None 3001 3 Point Lobos Marine Life 3 4.828 60 18.288 75 22.86 None 3002 3 Macabee BeachMarine Life 0.1 0.161 40 12.192 40 12.192 None 3003 3 Pinnacles Pinnacle 1 1.609 60 18.288 50 15.24 Mild 3004 3 Monastery Beach Marine Life 3 4.828 50 15.24 40 12.192 Surge IS 257 – Fall 2004 Skill Level Intermediate Intermediate Beginning Advanced Beginning Intermediate Beginning Advanced Beginning Intermediate Beginning Beginning Beginning Beginning 2004.09.20 - SLIDE 42 Sea Life = BIOLIFE Species NoCategory Common Name Species Name Length (cm) Length (in) Notes Graphic 90020 TriggerfishClown TriggerfishBallistoides conspicillum 50 19.685 90030 Snapper Red Emperor Lutjanus sebae 60 23.622 90050 Wrasse Giant Maori Wrasse Cheilinus undulatus 229 90.157 90070 Angelfish Blue Angelfish Pomacanthus nauarchus 30 11.811 90080 Cod Lunartail RockcodVariola louti 80 31.496 90090 Scorpionfish Firefish Pterois volitans 38 14.961 90100 ButterflyfishOrnate Butterflyfish Chaetodon Ornatissimus 19 7.4803 90110 Shark Swell Shark Cephaloscyllium ventriosum 102 40.157 90120 Ray Bat Ray Myliobatis californica 56 22.047 90130 Eel California Moray Gymnothorax mordax 150 59.055 90140 Cod Lingcod Ophiodon elongatus 150 59.055 IS 257 – Fall 2004 2004.09.20 - SLIDE 43 BIOSITE -- linking relation Species No Site No 90010 2001 90010 2002 90010 2003 90010 2004 90010 2005 90010 6001 90010 6003 90010 6004 90010 6005 90020 2001 90020 2002 IS 257 – Fall 2004 2004.09.20 - SLIDE 44 Shipwrecks = SHIPWRK Ship Name Site No Delaware 7007 F.S.Loop 4004 Gosford 4001 Great Isaac 7002 Lizzie D 7001 Mohawk 7004 R.P. Resor 7006 Star of Scotland 4002 Tolten 7008 USS Moody 4006 Valiant 4003 Category Type Interest TonnageLength (ft) Length (m) Beam (ft) Beam (m) Commercial Steam Freighter Treasure 1646 252 76.8096 37 11.2776 Commercial Steam Schooner Machinery 794 193 58.8264 39 11.8872 Commercial Barque Rigged Fixture Sail 2250 280 85.344 42 12.8016 Commercial Seagoing Tug Fixture 1117 185 56.388 37 11.2776 Commercial Tug/Rumrunner Treasure 122 84 25.6032 21 6.4008 PassengerOcean Liner Treasure 8140 402 122.5296 54 16.4592 Commercial Oil Tanker Treasure 7450 435 132.588 66.8 20.36064 PassengerBritish Q-Boat Treasure 1250 263 80.1624 35 10.668 Commercial Freighter Fixture 1858 280 85.344 43 13.1064 Military WWI Destroyer Treasure 1308 314 95.7072 31 9.4488 PassengerLuxury Motor Treasure Yacht 444 162.4 49.49952 26 7.9248 IS 257 – Fall 2004 Cause Date Sunk Comments Passengers/Crew Survivors Condition Graph Fire 66 66 Broken Deliberate 1/1/47 0 Scattered Fire Intact Collision 4/16/47 27 27 Intact Unknown 10/19/22 8 0 Intact Collision 1/25/35 163 118 Scattered Military 2/28/42 50 2 Broken Weather 1/22/42 5 4 Broken Military 3/13/42 28 1 Intact Deliberate 1/1/33 0 Intact Fire 12/17/30 25 25 Intact 2004.09.20 - SLIDE 45 Mapping to Other Models • Hierarchical – Need to make decisions about access paths • Network – Need to pre-specify all of the links and sets • Object-Oriented – What are the objects, datatypes, their methods and the access points for them • Object-Relational – Same as relational, but what new datatypes might be needed or useful (more on OR later) IS 257 – Fall 2004 2004.09.20 - SLIDE 46 Advantages of RDBMS • Possible to design complex data storage and retrieval systems with ease (and without conventional programming). • Support for ACID transactions – Atomic – Consistent – Independent – Durable IS 257 – Fall 2004 2004.09.20 - SLIDE 47 Advantages of RDBMS • Support for very large databases • Automatic optimization of searching (when possible) • RDBMS have a simple view of the database that conforms to much of the data used in businesses. • Standard query language (SQL) IS 257 – Fall 2004 2004.09.20 - SLIDE 48 Disadvantages of RDBMS • Until recently, no real support for complex objects such as documents, video, images, spatial or time-series data. (ORDBMS add support for these). • Often poor support for storage of complex objects from OOP languages (Disassembling the car to park it in the garage) • Still no efficient and effective integrated support for things like text searching within fields. IS 257 – Fall 2004 2004.09.20 - SLIDE 49 Lecture Outline • Review – Database Design -- Object-Oriented Modeling • Logical Design for the Diveshop database • Normalization • Access Database Creation IS 257 – Fall 2004 2004.09.20 - SLIDE 50 Database Creation in Access • Simplest to use a design view – wizards are available, but less flexible • Need to watch the default values • Helps to know what the primary key is, or if one is to be created automatically – Automatic creation is more complex in other RDBMS and ORDBMS • Need to make decision about the physical storage of the data IS 257 – Fall 2004 2004.09.20 - SLIDE 51 Database Creation in Access • Some Simple Examples IS 257 – Fall 2004 2004.09.20 - SLIDE 52 Next Time • Normalization and the Relational Model • Expanding and redesigning DiveShop IS 257 – Fall 2004 2004.09.20 - SLIDE 53