Database Design Object Oriented Modeling University of California
Database Design: Object. Oriented Modeling University of California, Berkeley School of Information Management and Systems SIMS 202: Information Organization and Retrieval 9/7/1999 Information Organization and Retrieval
Review • New Personal Database assignment • Database Design Process • Basics of ER Diagrams 9/7/1999 Information Organization and Retrieval
Database Design Process Application 1 External Model Application 2 Application 3 Application 4 External Model Application 1 Conceptual requirements Application 2 Conceptual requirements Application 3 Conceptual requirements Conceptual Model Logical Model Application 4 Conceptual requirements 9/7/1999 Information Organization and Retrieval Internal Model
Entity • An Entity is an object in the real world (or even imaginary worlds) about which we want or need to maintain information – Persons (e. g. : customers in a business, employees, authors) – Things (e. g. : purchase orders, meetings, parts, companies) Employee 9/7/1999 Information Organization and Retrieval
Attributes • Attributes are the significant properties or characteristics of an entity that help identify it and provide the information needed to interact with it or use it. (This is the Metadata for the entities. ) Birthdate First Middle Age Name Employee Last 9/7/1999 SSN Projects Information Organization and Retrieval
Relationships Student Attends Class Project Supplier 9/7/1999 Supplies project parts Information Organization and Retrieval Part
More Complex Relationships Manager 1/1/1 Employee 1/n/n Evaluation n/n/1 SSN Employee Date 4(2 -10) Assigned Project 1 Manages Employee 9/7/1999 Project Is Managed By Information Organization and Retrieval Project 1 Manages n
Ordering: Full ER Customer No Destination Name Destination no Dest Dive. Cust 1 Customer No 1 n Ship. Via n Dive. Ords n 1 Ship. Via 1 Destination Order No n Dive. Item n Order No Item No 1 Dive. Stok 9/7/1999 Information Organization and Retrieval Item No Ship. Via
Sites and Sea Life 2 Destination no Site No 1 Site No Species No Sites n Bio. Site n 1 Species No 9/7/1999 Bio. Life Information Organization and Retrieval
Sites and Shipwrecks Site No Destination no Sites 1 1/n Ship. Wrck Site No 9/7/1999 Information Organization and Retrieval
Dive. Shop ER Diagram Customer No Dive. Cust 1 Destination Name Destination no Customer No 1 n Destination no Site No 1 Site No Species No n Bio. Site Ship. Via n Dive. Ords Destination n Order No n 1 1/n 9/7/1999 Dive. Item Ship. Wrck n Ship. Via Site No 1 Order No Item No n 1 Species No 1 1 1 Sites n Dive. Stok Bio. Life Information Organization and Retrieval Item No Ship. Via
Today • Object Oriented Modeling and UML • Semantic Object Model – Introduced in earlier editions of Kroenke – An alternative approach to modeling the sorts of entities and relationships of a database 9/7/1999 Information Organization and Retrieval
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 9/7/1999 Information Organization and Retrieval
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 9/7/1999 Information Organization and Retrieval
Unified Modeling Language (UML) • Combined three competing methods • Can be used for graphically depicting 9/7/1999 Information Organization and Retrieval
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 9/7/1999 Information Organization and Retrieval
UML Relationships • A relationship is a connection between or among model elements. • The UML defines four basic kinds of relationships: – Association – Dependency – Generalization – Realization 9/7/1999 Information Organization and Retrieval
UML Diagrams • The UML defines nine types of diagrams: – activity diagram – class diagram • Describes the data and some behavioral (operations) of a system – – – – 9/7/1999 collaboration diagram component diagram deployment diagram object diagram sequence diagram statechart diagram use case diagram Information Organization and Retrieval
Class Diagrams • A class diagram is a diagram that shows a set of classes, interfaces, and/or collaborations and the relationships among these elements. 9/7/1999 Information Organization and Retrieval
UML Class Diagram DIVEORDS Order No Customer No Sale Date Shipvia Payment. Method CCNumber No of People Depart Date Return Date Destination Vacation Cost Class Name List of Attributes Calc. Total. Invoice() Calc. Equipment() 9/7/1999 Information Organization and Retrieval List of operations
Object Diagrams 307: DIVORDS Order No = 307 Customer No = 1480 Sale Date = 9/1/99 Ship Via = UPS Payment. Method = Visa CCNumber = 12345 678 90 CCExp. Date = 1/1/01 No of People = 2 Depart Date = 11/8/00 Return Date = 11/15/00 Destination = Fiji Vacation Cost = 10000 9/7/1999 Information Organization and Retrieval
Differences from Entities in ER • Entities can be represented by Class diagrams • But Classes of objects also have additional operations associated with them 9/7/1999 Information Organization and Retrieval
Operations • Three basic types for database – Constructor – Query – Update 9/7/1999 Information Organization and Retrieval
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. • 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 nary association. 9/7/1999 Information Organization and Retrieval
Associations: Unary relationships * 0. . 1 Person Is-married-to 0. . 1 manager 0. . 1 9/7/1999 Employee Information Organization and Retrieval manages
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 Many-to-many 9/7/1999 Information Organization and Retrieval * Course
Associations: Ternary Relationships Part * Vendor 9/7/1999 * Supplies Information Organization and Retrieval * Warehouse
Association Classes Registers-for Student * Course * Computer Account Registration _________ acct. ID Term issues Password * 0. . 1 Grade Server. Space ________ Check. Eligibility() 9/7/1999 Information Organization and Retrieval
Derived Attributes, Associations, and Roles Course Student Course Offering ____________ Scheduled-for name Registers-for crse. Code term ssn * crse. Title * * 1 section date. Of. Birth credit. Hrs time Derived /age location attribute * * /participant Derived role {age = current. Date – date. Of. Birth} /Takes Derived association 9/7/1999 Information Organization and Retrieval
Generalization Employee ______ emp. Name emp. Number address date. Hired ______ print. Label() Hourly Employee ________ Hourly. Rate ________ compute. Wages() 9/7/1999 Salaried Employee ________ Annual Sal stockoption ________ Information Organization and Retrieval Contributepension() Consultant ________ contract. Number billing. Rate ________ compute. Fees()
Semantic Objects • Very similar to UML representation • Similar to an Entity • Represents something in the organization’s work environment that we want to keep information about. • Formally “A named collection of attributes that sufficiently describes a distinct identity” (Kroenke, p. 74) 9/7/1999 Information Organization and Retrieval
Semantic Objects • Semantics objects are grouped into classes – Object class names are spelled in capitals (e. g. STUDENT, DEPARTMENT, DIVECUST, etc. ) • SO’s have collections of attributes • SO’s represent distincts identities – Difference between “Objects” and “Object Instances” • Need not be physical entities (e. g. P. O. ’s) 9/7/1999 Information Organization and Retrieval
SOM Attributes • Three types: – Simple attributes • have a single value – Group attributes • composites of other attributes (e. g. Address is a composite of Street, City, State, Zip) – Semantic Object Attributes • establish a relationship between one semantic object and another. 9/7/1999 Information Organization and Retrieval
SOM Example DEPARTMENT Department. Name Campus. Address Building Office. Number id 1. 1 Phone. Number Fax. Phone. Number 0. 1 COLLEGE 1. 1 0. 1 1. N PROFESSOR STUDENT 9/7/1999 1. N Information Organization and Retrieval
Object Instance School of Information Management and Systems South Hall 202 642 -1464 642 -9980 642 -1465 642 -5814 School of Information Management and Systems Larson Hearst Varian Smith 9/7/1999 Etc. . . Information Organization and Retrieval
Developing a Semantic Object Model • We will look at a small business -- a diveshop that offers diving adventure vacations • Assume that we have done interviews with the business and found out the following information about the forms used and types of information kept in files and used for business operations. . . 9/7/1999 Information Organization and Retrieval
Primary Business Operations • The shop takes orders from customers for dive vacations. • It ships information about the dive vacation to the customers. • It rents diving equipment for the divers going on the trips (these may include additional people other than the customer) • It bills the customer for the vacation and for equipment rental or sales. 9/7/1999 Information Organization and Retrieval
Business Operations (cont. ) • It arranges sub-trips to particular dive sites at the primary location. • It provides information about the features of various sites to help customers choose their destinations. – Features include sea life found at the location and shipwrecks 9/7/1999 Information Organization and Retrieval
Business Operations (cont. ) • Each dive order (or sale or trip) is on an invoice to one customer. – Invoices contain: • Line items for each type of equipment ordered, • Total amount due for the invoice, • Customer information: – Name, address, phone, credit card info. • Information must be kept on inventory of dive equipment. • There are multiple types of dive equipment: – The prices charged for sale or rental are maintained. 9/7/1999 Information Organization and Retrieval
Business Operations (cont. ) • Destination information includes: – Name of the destination – information about the location (accomodations, night life, travel cost, average temperatures for different times of the year • Destinations have associate dive sites. • Dive Sites have associated features – Sea life – Shipwrecks 9/7/1999 Information Organization and Retrieval
Business Operations (cont. ) • One record is kept for each order by a customer and will include the method of payment, total price, and location information. (I. e. Customers may have multiple orders) • The company needs to know how an order is to be shipped. • The shop has to keep track of what equipment is on-hand when replacements or additional equipment is needed 9/7/1999 Information Organization and Retrieval
Application of SOM to Diveshop DIVECUST Name Address Street City State. Province ZIPPostal. Code Country Phone First. Contact 1. 1 1. 1 DIVEORDS 9/7/1999 1. N Information Organization and Retrieval 1. 1
DIVEORDS Order. No Sale. Date DIVECUST id SHIPVIA DESTINATION DIVEITEM Payment. Method CCNumber CCExp. Date No. Of. People Depart. Date Return. Date Vacation. Cost 9/7/1999 Information Organization and Retrieval
Assignment 1 • What are the answers? – Access examples 9/7/1999 Information Organization and Retrieval
- Slides: 44