SLIDE 1IS Fall 2002 Database Design: Object- Oriented Modeling University of California, Berkeley School of Information Management and Systems SIMS 202: Information Organization and Retrieval
SLIDE 2IS Fall 2002 Lecture Outline Review –ER Diagrams –Developing the Conceptual Model –Assignment 1 Discussion Database Design cont. Object- Oriented Modeling Logical Design for the Diveshop database
SLIDE 3IS Fall 2002 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)
SLIDE 4IS Fall 2002 Entities Customer Dive Order Line item Shipping information Dive Equipment/ Stock/Inventory Dive Locations Dive Sites Sea Life Shipwrecks
SLIDE 5IS Fall 2002 Ordering: Full ER Customer No ShipVia Dest ShipVia DiveStok DiveItem DiveOrds DiveCust Customer No ShipVia Order No Order No Item No Item No Destination Name Destination no n n n n n
SLIDE 6IS Fall 2002 Destination/ Sites Dest Sites DiveOrds Customer No Order No Destination Name Destination Site No Destination no Destination no 1 1 n n
SLIDE 7IS Fall 2002 Sites and Sea Life 2 Sites BioSite BioLife Species No Site No Destination no Species No 1 1 n n
SLIDE 8IS Fall 2002 Sites and Shipwrecks Sites ShipWrck Site No Destination no Site No 1/n 1
SLIDE 9IS Fall 2002 DiveShop ER Diagram Customer No ShipVia Dest Sites BioSite ShipVia ShipWrck BioLife DiveStok DiveItem DiveOrds DiveCust Customer No ShipVia Order No Order No Item No Item No Destination Name Destination Species No Site No Destination no Site No Destination no Species No Site No /n 1 1n n n n n n n n 1
SLIDE 10IS Fall 2002 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)
SLIDE 11IS Fall 2002 Assignment 1 Discussion Problems?
SLIDE 12IS Fall 2002 Lecture Outline Review –ER Diagrams –Developing the Conceptual Model –Assignment 1 Discussion Database Design cont. Object- Oriented Modeling Logical Design for the Diveshop database
SLIDE 13IS Fall 2002 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”, 5 th edition)
SLIDE 14IS Fall 2002 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
SLIDE 15IS Fall 2002 Unified Modeling Language (UML) Combined three competing methods Can be used for graphically depicting –Software designs and interaction –Database –Processes
SLIDE 16IS Fall 2002 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
SLIDE 17IS Fall 2002 UML Relationships An relationship is a connection between or among model elements. The UML defines four basic kinds of relationships: –Association –Dependency –Generalization –Realization
SLIDE 18IS Fall 2002 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
SLIDE 19IS Fall 2002 Class Diagrams A class diagram is a diagram that shows a set of classes, interfaces, and/or collaborations and the relationships among these elements.
SLIDE 20IS Fall 2002 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() Class Name List of Attributes List of operations
SLIDE 21IS Fall 2002 Object Diagrams 307:DIVORDS Order No = 307 Customer No = 1480 Sale Date = 9/1/99 Ship Via = UPS PaymentMethod = Visa CCNumber = CCExpDate = 1/1/01 No of People = 2 Depart Date = 11/8/00 Return Date = 11/15/00 Destination = Fiji Vacation Cost = 10000
SLIDE 22IS Fall 2002 Differences from Entities in ER Entities can be represented by Class diagrams But Classes of objects also have additional operations associated with them
SLIDE 23IS Fall 2002 Operations Three basic types for database –Constructor –Query –Update
SLIDE 24IS Fall 2002 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.
SLIDE 25IS Fall 2002 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.
SLIDE 26IS Fall 2002 Associations: Unary relationships Person Is-married-to 0..1 Employee manages * 0..1 manager
SLIDE 27IS Fall 2002 Associations: Binary Relationship Employee Parking Place One-to-one Is-assigned0..1 Product Line Product One-to-many contains1 * StudentCourse Many-to-many Registers-for* *
SLIDE 28IS Fall 2002 Associations: Ternary Relationships VendorWarehouse * * Supplies Part *
SLIDE 29IS Fall 2002 Association Classes StudentCourse Registers-for * * Registration ________________ Term Grade ________________ CheckEligibility() Computer Account _________________ acctID Password ServerSpace *0..1 issues
SLIDE 30IS Fall 2002 Derived Attributes, Associations, and Roles Student _________ name ssn dateOfBirth /age Course Offering ____________ term section time location Registers-for * 1 Course ____________ crseCode crseTitle creditHrs * * Scheduled-for {age = currentDate – dateOfBirth} * * /Takes /participant Derived attribute Derived role Derived association
SLIDE 31IS Fall 2002 Generalization Employee ____________ empName empNumber address dateHired ____________ printLabel() Hourly Employee _______________ HourlyRate _______________ computeWages() Salaried Employee _______________ Annual Sal stockoption _______________ Contributepension() Consultant _______________ contractNumber billingRate _______________ computeFees()
SLIDE 32IS Fall 2002 Other Diagramming methods SOM (Semantic Object Model) Object Definition Language (ODL) –Not really diagramming Access relationships display Hybrids
SLIDE 33IS Fall 2002 Application of SOM to Diveshop DIVECUST Address Street City StateProvince ZIPPostalCode Country Phone FirstContact Name DIVEORDS N 1.1
SLIDE 34IS Fall 2002 DIVEORDS id OrderNo SaleDate SHIPVIA DESTINATION DIVEITEM PaymentMethod CCNumber CCExpDate NoOfPeople DepartDate ReturnDate VacationCost DIVECUST
SLIDE 35IS Fall 2002 DiveShop ER Diagram Customer No ShipVia Dest Sites BioSite ShipVia ShipWrck BioLife DiveStok DiveItem DiveOrds DiveCust Customer No ShipVia Order No Order No Item No Item No Destination Name Destination Species No Site No Destination no Site No Destination no Species No Site No /n 1 1n n n n n n n n 1
SLIDE 36IS Fall 2002 Entities Customer Dive Order Line item Shipping information Dive Equipment Stock/Inventory Dive Locations Dive Sites Sea Life Shipwrecks
SLIDE 37IS Fall 2002 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
SLIDE 38IS Fall 2002 Customer = DIVECUST
SLIDE 39IS Fall 2002 Dive Order = DIVEORDS
SLIDE 40IS Fall 2002 Line item = DIVEITEM
SLIDE 41IS Fall 2002 Shipping information = SHIPVIA
SLIDE 42IS Fall 2002 Dive Equipment Stock= DIVESTOK
SLIDE 43IS Fall 2002 Dive Locations = DEST
SLIDE 44IS Fall 2002 Dive Sites = SITE
SLIDE 45IS Fall 2002 Sea Life = BIOLIFE
SLIDE 46IS Fall 2002 BIOSITE -- linking relation
SLIDE 47IS Fall 2002 Shipwrecks = SHIPWRK
SLIDE 48IS Fall 2002 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.
SLIDE 49IS Fall 2002 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