Post on 18-Dec-2015
IS 257 - Fall 2002 2002.08.29 - SLIDE 1
Database Design: Object-Oriented Modeling
University of California, Berkeley
School of Information Management and Systems
SIMS 202: Information Organization and Retrieval
IS 257 - Fall 2002 2002.08.29 - SLIDE 2
Lecture Outline
• Review– ER Diagrams– Developing the Conceptual Model– Assignment 1 Discussion
• Database Design cont. Object-Oriented Modeling
• Logical Design for the Diveshop database
IS 257 - Fall 2002 2002.08.29 - SLIDE 3
Developing a Conceptual Model
• Overall view of the database that integrates all the needed information discovered during the requirements analysis.
• Elements of the Conceptual Model are represented by diagrams, Entity-Relationship or ER Diagrams, that show the meanings and relationships of those elements independent of any particular database systems or implementation details.
• Can also be represented using other modeling tools (such as UML)
IS 257 - Fall 2002 2002.08.29 - SLIDE 4
Entities
• Customer
• Dive Order
• Line item
• Shipping information
• Dive Equipment/ Stock/Inventory
• Dive Locations
• Dive Sites
• Sea Life
• Shipwrecks
IS 257 - Fall 2002 2002.08.29 - SLIDE 5
Ordering: Full ER
CustomerNo
ShipVia
DestShipVia
DiveStok
DiveItem
DiveOrds
DiveCust
CustomerNo
ShipVia
OrderNo
OrderNo
ItemNo
ItemNo
DestinationName
Destination
Destinationno 1
1
1
1
1n
n
n
n
n
IS 257 - Fall 2002 2002.08.29 - SLIDE 6
Destination/ Sites
Dest
Sites
DiveOrds
CustomerNo
OrderNo
DestinationName
DestinationSite No
Destinationno
Destinationno
1
1
n
n
IS 257 - Fall 2002 2002.08.29 - SLIDE 7
Sites and Sea Life 2
Sites
BioSite
BioLifeSpeciesNo
Site No
Site No
Destinationno
SpeciesNo
1
1
n
n
IS 257 - Fall 2002 2002.08.29 - SLIDE 8
Sites and Shipwrecks
Sites
ShipWrck
Site NoDestination
no
Site No
1/n
1
IS 257 - Fall 2002 2002.08.29 - SLIDE 9
DiveShop ER DiagramCustomer
No
ShipVia
Dest
Sites
BioSite
ShipVia
ShipWrck
BioLife DiveStok
DiveItem
DiveOrds
DiveCust
CustomerNo
ShipVia
OrderNo
OrderNo
ItemNo
ItemNo
DestinationName
Destination
SpeciesNo
Site No
Destinationno
Site No
Destinationno
SpeciesNo
Site No
1
1
1
1
1
1
1/n
1
1n
n
n
n
n
n
n
n
1
IS 257 - Fall 2002 2002.08.29 - SLIDE 10
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 2002 2002.08.29 - SLIDE 11
Assignment 1 Discussion
• Problems?
IS 257 - Fall 2002 2002.08.29 - SLIDE 12
Lecture Outline
• Review– ER Diagrams– Developing the Conceptual Model– Assignment 1 Discussion
• Database Design cont. Object-Oriented Modeling
• Logical Design for the Diveshop database
IS 257 - Fall 2002 2002.08.29 - SLIDE 13
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 2002 2002.08.29 - SLIDE 14
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 2002 2002.08.29 - SLIDE 15
Unified Modeling Language (UML)
• Combined three competing methods
• Can be used for graphically depicting– Software designs and interaction– Database– Processes
IS 257 - Fall 2002 2002.08.29 - SLIDE 16
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 2002 2002.08.29 - SLIDE 17
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 2002 2002.08.29 - SLIDE 18
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 2002 2002.08.29 - SLIDE 19
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 2002 2002.08.29 - SLIDE 20
UML Class Diagram
DIVEORDS
Order NoCustomer NoSale DateShipviaPaymentMethodCCNumberNo of PeopleDepart DateReturn DateDestinationVacation Cost
CalcTotalInvoice()CalcEquipment()
Class Name
List of Attributes
List of operations
IS 257 - Fall 2002 2002.08.29 - SLIDE 21
Object Diagrams
307:DIVORDS
Order No = 307Customer No = 1480Sale Date = 9/1/99Ship Via = UPSPaymentMethod = VisaCCNumber = 12345 678 90CCExpDate = 1/1/01No of People = 2Depart Date = 11/8/00Return Date = 11/15/00Destination = FijiVacation Cost = 10000
IS 257 - Fall 2002 2002.08.29 - SLIDE 22
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 2002 2002.08.29 - SLIDE 23
Operations
• Three basic types for database– Constructor– Query– Update
IS 257 - Fall 2002 2002.08.29 - SLIDE 24
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 2002 2002.08.29 - SLIDE 25
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 2002 2002.08.29 - SLIDE 26
Associations: Unary relationships
PersonIs-married-to
0..1
0..1
Employeemanages
*
0..1 manager
IS 257 - Fall 2002 2002.08.29 - SLIDE 27
Associations: Binary Relationship
EmployeeParkingPlace
One-to-one
Is-assigned0..1 0..1
ProductLine
Product
One-to-many
contains1 *
Student Course
Many-to-many
Registers-for* *
IS 257 - Fall 2002 2002.08.29 - SLIDE 28
Associations: Ternary Relationships
Vendor Warehouse* *Supplies
Part
*
IS 257 - Fall 2002 2002.08.29 - SLIDE 29
Association Classes
Student CourseRegisters-for
* *
Registration________________TermGrade________________CheckEligibility()
Computer Account_________________
acctIDPassword
ServerSpace* 0..1issues
IS 257 - Fall 2002 2002.08.29 - SLIDE 30
Derived Attributes, Associations, and Roles
Student_________
namessn
dateOfBirth/age
Course Offering
____________term
sectiontime
location
Registers-for
* 1
Course ____________
crseCodecrseTitlecreditHrs
* *
Scheduled-for
{age = currentDate – dateOfBirth}
* *
/Takes
/participant
Derivedattribute
Derived role
Derived association
IS 257 - Fall 2002 2002.08.29 - SLIDE 31
GeneralizationEmployee
____________empName
empNumberaddress
dateHired____________
printLabel()
Hourly Employee_______________
HourlyRate_______________computeWages()
Salaried Employee_______________
Annual Salstockoption
_______________Contributepension()
Consultant_______________contractNumber
billingRate_______________
computeFees()
IS 257 - Fall 2002 2002.08.29 - SLIDE 32
Other Diagramming methods
• SOM (Semantic Object Model)
• Object Definition Language (ODL)– Not really diagramming
• Access relationships display
• Hybrids
IS 257 - Fall 2002 2002.08.29 - SLIDE 33
Application of SOM to Diveshop
DIVECUST
Address Street City StateProvince ZIPPostalCode CountryPhoneFirstContact
Name
DIVEORDS
1.1
1.1
1.1
1.1
1.1
1.1
1.1
1.1
1.N
1.1
IS 257 - Fall 2002 2002.08.29 - SLIDE 34
DIVEORDS
DIVEORDSid OrderNoSaleDate
SHIPVIA
DESTINATION
DIVEITEMPaymentMethodCCNumberCCExpDateNoOfPeopleDepartDateReturnDateVacationCost
DIVECUST
IS 257 - Fall 2002 2002.08.29 - SLIDE 35
DiveShop ER DiagramCustomer
No
ShipVia
Dest
Sites
BioSite
ShipVia
ShipWrck
BioLife DiveStok
DiveItem
DiveOrds
DiveCust
CustomerNo
ShipVia
OrderNo
OrderNo
ItemNo
ItemNo
DestinationName
Destination
SpeciesNo
Site No
Destinationno
Site No
Destinationno
SpeciesNo
Site No
1
1
1
1
1
1
1/n
1
1n
n
n
n
n
n
n
n
1
IS 257 - Fall 2002 2002.08.29 - SLIDE 36
Entities
• Customer• Dive Order• Line item• Shipping information• Dive Equipment
Stock/Inventory• Dive Locations
• Dive Sites• Sea Life• Shipwrecks
IS 257 - Fall 2002 2002.08.29 - SLIDE 37
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 2002 2002.08.29 - SLIDE 38
Customer = DIVECUST
Customer NoName Street City State/Prov Zip/Postal CodeCountry Phone First Contact1480 Louis Jazdzewski2501 O'ConnorNew OrleansLA 60332 U.S.A. (902) 555-88881/29/951481 Barbara Wright6344 W. FreewaySan FranciscoCA 95031 U.S.A. (415) 555-43212/2/931909 Stephen Bredenburg559 N.E. 167 PlaceIndianapolisIN 46241 U.S.A. (317) 555-36441/5/931913 Phillip Davoust123 First StreetBerkeley CA 94704 U.S.A. (415) 555-91843/9/981969 David Burgett320 Montgomery StreetSeattle WA 98105 U.S.A. (206) 555-75803/12/992001 Mary Rioux1701 Gateway Blvd. #385Pueblo CO 81002 U.S.A. (719) 555-20103/15/972306 Kim Lopez 14134 Nottingham LaneHonolulu HI 96826 U.S.A. (808) 555-50501/29/992589 Hiram Marley7233 Mill Run DriveSan FranciscoCA 94123 U.S.A. (415) 555-64302/18/993154 Tanya Kulesa505 S. Flower, Mail Stop 48943New York NY 10032 U.S.A. (212) 555-67501/30/993333 Charles Sekaron110 East Park Avenue, Box 8Miller SD 57362 U.S.A. (613) 555-43333/16/983684 Lowell Lutz915 E. FeslerDallas TX 75043 U.S.A. (214) 555-27222/15/994158 Keith Lucas56 South EuclidChicago IL 60542 U.S.A. (312) 555-43103/17/984175 Karen Ng 2134 Elmhill PikeKlamath FallsOR 97603 U.S.A. (503) 555-47003/20/995510 Ken Soule 58 Sansome StreetAurora CO 89022 U.S.A. (303) 555-66952/5/99
IS 257 - Fall 2002 2002.08.29 - SLIDE 39
Dive Order = DIVEORDS
Order No Customer NoSale Date Ship Via PaymentMethodCcNumber CcExpDateNo Of PeopleDepart DateReturn DateDestinationVacationCost307 1480 9/1/99 UPS Visa 12345 678 90 1/1/01 2 11/8/00 11/15/00 Fiji 10000310 1481 9/1/99 FedEx Check 1 4/4/00 4/18/00 Santa Barbara 6000313 1909 9/1/99 Walk In Visa 456456456 9/11/00 4 6/27/00 7/11/00 Cozumel 8000314 1913 9/1/99 FedEx Check 3 2/7/00 2/14/00 Monterey 6000317 1969 9/1/99 FedEx AmEx 432432432 12/31/02 4 5/9/00 5/16/00 Fiji 20000320 2001 9/1/99 Walk In Cash 1 10/10/00 10/17/00 Santa Barbara 3000321 2306 9/1/99 Emery Master Card1112223334 8/12/00 1 3/15/00 4/12/00 New Jersey 8000325 2589 9/1/99 Emery AmEx 332332332 12/10/99 1 3/15/00 4/12/00 New Jersey 8000326 3333 9/1/99 FedEx Money Order 2 2/10/00 2/17/00 Monterey 4000327 3684 9/1/99 DHL Master Card122122321 11/9/99 4 3/10/00 3/23/00 Florida 24000329 4158 9/1/99 Walk In Cash 1 5/4/00 5/15/00 Cozumel 1571330 4175 9/1/99 FedEx Check 2 7/3/00 7/10/00 Florida 6000331 5510 9/1/99 FedEx Money Order 6 6/20/00 6/30/00 Santa Barbara 36000333 5926 9/1/99 DHL Discover 123123123 12/21/00 2 6/10/00 6/17/00 Fiji 10000336 5719 9/1/99 FedEx Cash 10 4/2/00 4/24/00 Great Barrier Reef200000
IS 257 - Fall 2002 2002.08.29 - SLIDE 40
Line item = DIVEITEM
Order No Item No Rental/SaleQty Line Note307 90010 Rental 4307 90020 Rental 1 This is our most popular mask.307 90021 Rental 1307 90030 Rental 2 These are our best selling fins.307 90051 Rental 2310 90011 Rental 1310 90045 Rental 1310 90059 Rental 1 A good weight belt for beginners.310 90074 Rental 1310 90078 Rental 1313 90127 Sale 1 Holds 10 cubic feet of cargo.314 90072 Rental 3314 90094 Rental 3314 90100 Rental 3317 90012 Sale 2
IS 257 - Fall 2002 2002.08.29 - SLIDE 41
Shipping information = SHIPVIA
Ship Via Ship CostDHL 8Emery 11FedEx 12UPS 10US Mail 6
IS 257 - Fall 2002 2002.08.29 - SLIDE 42
Dive Equipment Stock= DIVESTOK
Item No DescriptionEquipment ClassOn Hand Reorder PointCost Sale Price Rental Price90010 Shotgun 2 Snorkel - ClearSnorkel 12 2 $18.00 $30.00 $2.0090011 Shotgun 2 Snorkel - RedSnorkel 12 2 $18.00 $30.00 $2.0090012 Shotgun 2 Snorkel - TealSnorkel 11 2 $18.00 $30.00 $2.0090020 Tri-Vent Mask - ClearMask 14 2 $62.50 $100.00 $5.0090021 Tri-Vent Mask - RedMask 10 2 $62.50 $100.00 $5.0090022 Tri-Vent Mask - TealMask 14 2 $62.50 $100.00 $7.0090023 Quad Vision Mask - ClearMask 11 2 $48.25 $80.00 $7.0090024 Quad Vision Mask - RedMask 13 2 $48.25 $80.00 $7.0090025 Quad Vision Mask - TealMask 10 2 $48.25 $80.00 $10.0090030 Sea Wing Fins - ClearFins 12 2 $60.00 $100.00 $12.0090031 Sea Wing Fins - RedFins 11 2 $60.00 $100.00 $12.0090032 Sea Wing Fins - TealFins 12 2 $60.00 $100.00 $12.0090033 Jet Fin - BlackFins 14 2 $30.00 $60.00 $10.0090040 D350 Second StageRegulator 11 1 $162.50 $270.00 $20.0090041 G250 Second StageRegulator 13 1 $144.50 $240.00 $20.0090042 G200 Second StageRegulator 12 1 $105.25 $175.00 $20.00
IS 257 - Fall 2002 2002.08.29 - SLIDE 43
Dive Locations = DEST
Destination NoDestination NameAvg Temp (F)Avg Temp (C)Spring Temp (F)Spring Temp (C)Summer Temp (F)Summer Temp (C)Fall Temp (F)Fall Temp (C)Winter Temp (F)Winter Temp (C)AccomodationsNight Life Body of WaterTravel Cost1 Cozumel 78 25.556 76 24.444 84 28.889 78 25.556 74 23.333 Cheap Sleepy Caribbean 10002 Great Barrier Reef80 26.667 76 24.444 84 28.889 78 25.556 76 24.444 Moderate Pleasant Coral Sea 50003 Monterey 60 15.556 62 16.667 64 17.778 64 17.778 58 14.444 ExpensiveWild Pacific 20004 Santa Barbara 75 23.889 73 22.777 78 25.556 72 22.222 70 21.111 ExpensiveWild Pacific 30005 Florida 77 25 75 23.889 85 29.444 78 25.556 70 21.111 Moderate Pleasant Caribbean 30006 Fiji 75 23.889 76 24.444 80 26.667 74 23.333 70 21.111 ExpensiveSleepy South Pacific 50007 New J ersey 57 13.889 57 13.89 60 15.556 58 14.444 53 11.667 ExpensivePleasant Atlantic 2000
IS 257 - Fall 2002 2002.08.29 - SLIDE 44
Dive Sites = SITE
Site No Destination NoSite Name Site HighlightSite NotesDistance from Town (m)Distance from Town (km)Depth (ft)Depth (m) Visibility (ft)Visibility (m)Current Skill Level1001 1 Palancar Reef Reef 10 16.09 100 30.48 150 45.72 Strong Intermediate1002 1 Santa Rosa ReefReef 8 12.87 80 24.384 150 45.72 Strong Intermediate1003 1 Chancanab ReefReef 4 6.437 60 18.288 100 30.48 Mild Beginning1004 1 Punta Sur Reef 13 20.92 120 36.576 175 53.34 Strong Advanced1005 1 Yocab Reef Reef 6 9.656 50 15.24 100 30.48 Mild Beginning2001 2 Heron Island Reef 50 80.47 90 27.432 150 45.72 Mild Intermediate2002 2 Cod Hole Fish 45 72.42 50 15.24 150 45.72 Mild Beginning2003 2 Butterfly Bay Caves 20 32.19 70 21.336 70 21.336 None Advanced2004 2 Wheeler Reef Marine Life 30 48.28 50 15.24 125 38.1 Mild Beginning2005 2 Watanabe Marine Life 130 209.2 150 45.72 200 60.96 None Intermediate3001 3 Point Lobos Marine Life 3 4.828 60 18.288 75 22.86 None Beginning3002 3 Macabee BeachMarine Life 0.1 0.161 40 12.192 40 12.192 None Beginning3003 3 Pinnacles Pinnacle 1 1.609 60 18.288 50 15.24 Mild Beginning3004 3 Monastery BeachMarine Life 3 4.828 50 15.24 40 12.192 Surge Beginning
IS 257 - Fall 2002 2002.08.29 - SLIDE 45
Sea Life = BIOLIFE
Species NoCategory Common Name Species Name Length (cm)Length (in)Notes Graphic90020 TriggerfishClown TriggerfishBallistoides conspicillum50 19.68590030 Snapper Red Emperor Lutjanus sebae 60 23.62290050 Wrasse Giant Maori WrasseCheilinus undulatus 229 90.15790070 Angelfish Blue Angelfish Pomacanthus nauarchus30 11.81190080 Cod Lunartail RockcodVariola louti 80 31.49690090 ScorpionfishFirefish Pterois volitans 38 14.96190100 ButterflyfishOrnate ButterflyfishChaetodon Ornatissimus19 7.480390110 Shark Swell Shark Cephaloscyllium ventriosum102 40.15790120 Ray Bat Ray Myliobatis californica 56 22.04790130 Eel California Moray Gymnothorax mordax 150 59.05590140 Cod Lingcod Ophiodon elongatus 150 59.055
IS 257 - Fall 2002 2002.08.29 - SLIDE 46
BIOSITE -- linking relation
Species No Site No90010 200190010 200290010 200390010 200490010 200590010 600190010 600390010 600490010 600590020 200190020 2002
IS 257 - Fall 2002 2002.08.29 - SLIDE 47
Shipwrecks = SHIPWRK
Ship Name Site No Category Type Interest TonnageLength (ft)Length (m)Beam (ft)Beam (m) Cause Date Sunk CommentsPassengers/CrewSurvivorsCondition GraphicDelaware 7007 CommercialSteam FreighterTreasure 1646 252 76.8096 37 11.2776 Fire 66 66 BrokenF.S.Loop 4004 CommercialSteam SchoonerMachinery 794 193 58.8264 39 11.8872 Deliberate 1/1/47 0 ScatteredGosford 4001 CommercialBarque Rigged SailFixture 2250 280 85.344 42 12.8016 Fire IntactGreat Isaac 7002 CommercialSeagoing TugFixture 1117 185 56.388 37 11.2776 Collision 4/16/47 27 27 IntactLizzie D 7001 CommercialTug/RumrunnerTreasure 122 84 25.6032 21 6.4008 Unknown 10/19/22 8 0 IntactMohawk 7004 PassengerOcean LinerTreasure 8140 402 122.5296 54 16.4592 Collision 1/25/35 163 118 ScatteredR.P . Resor 7006 CommercialOil TankerTreasure 7450 435 132.588 66.8 20.36064 Military 2/28/42 50 2 BrokenStar of Scotland4002 PassengerBritish Q-BoatTreasure 1250 263 80.1624 35 10.668 Weather 1/22/42 5 4 BrokenTolten 7008 CommercialFreighter Fixture 1858 280 85.344 43 13.1064 Military 3/13/42 28 1 IntactUSS Moody 4006 Military WWI DestroyerTreasure 1308 314 95.7072 31 9.4488 Deliberate 1/1/33 0 IntactValiant 4003 PassengerLuxury Motor YachtTreasure 444 162.4 49.49952 26 7.9248 Fire 12/17/30 25 25 Intact
IS 257 - Fall 2002 2002.08.29 - SLIDE 48
Assignment 2: Due Oct. 1
• The following information should be turned in for the preliminary design of your personal database project.
1. A general description of the data you will be using for the database, and what uses you might expect the database to have.
2. A preliminary data dictionary for the entities and attributes and format of the data elements of the database. You should have at least 5 entities with some logical connections between them. The data dictionary consists of all of the attributes that you have identified for each entity, along with indication of whether the attribute is a primary key (or part of a primary key), and what format the data will be (e.g.: text, decimal number, integer, etc.)
3. Produce an entity-relationship diagram of the database OR a UML diagram.
• These will be preliminary design specifications, so do not feel that you must follow everything that you describe here in the final database design.
IS 257 - Fall 2002 2002.08.29 - SLIDE 49
Next Time
• Normalization
• Normal Forms
• For next 2 weeks: Guest speakers– Sep 17: Marti Hearst on Flamenco.– Sep 24: Mark Butler, Interwoven – Sep 26: Avi Rappoport, Search.com