9/7/1999information organization and retrieval database design: object- oriented modeling university...

Post on 02-Jan-2016

216 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

9/7/1999 Information Organization and Retrieval

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

ConceptualModel

LogicalModel

External Model

Conceptual requirements

Conceptual requirements

Conceptual requirements

Conceptual requirements

Application 1

Application 1

Application 2 Application 3 Application 4

Application 2

Application 3

Application 4

External Model

External Model

External Model

Internal Model

9/7/1999 Information Organization and Retrieval

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.)

Employee

Last

Middle

First

Name SSN

Age

Birthdate

Projects

9/7/1999 Information Organization and Retrieval

Relationships

ClassAttendsStudent

PartSuppliesproject

partsSupplier

Project

9/7/1999 Information Organization and Retrieval

More Complex Relationships

ProjectEvaluationEmployee

Manager

1/n/n

1/1/1

n/n/1

ManagesEmployee

ProjectAssignedEmployee 4(2-10) 1

SSN ProjectDate

Manages

Is Managed By

1

n

9/7/1999 Information Organization and Retrieval

Ordering: Full ERCustomer

No

ShipVia

DestShipVia

DiveStok

DiveItem

DiveOrds

DiveCust

CustomerNo

ShipVia

OrderNo

OrderNo

ItemNo

ItemNo

DestinationName

Destination

Destinationno 1

1

1

1

1n

n

n

n

n

9/7/1999 Information Organization and Retrieval

Sites and Sea Life 2

Sites

BioSite

BioLifeSpeciesNo

Site No

Site No

Destinationno

SpeciesNo

1

1

n

n

9/7/1999 Information Organization and Retrieval

Sites and Shipwrecks

Sites

ShipWrck

Site NoDestination

no

Site No

1/n

1

9/7/1999 Information Organization and Retrieval

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

9/7/1999 Information Organization and Retrieval

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

– collaboration diagram– component diagram– deployment diagram– object diagram– sequence diagram– statechart diagram– use case diagram

9/7/1999 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 NoCustomer NoSale DateShipviaPaymentMethodCCNumberNo of PeopleDepart DateReturn DateDestinationVacation Cost

CalcTotalInvoice()CalcEquipment()

Class Name

List of Attributes

List of operations

9/7/1999 Information Organization and Retrieval

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

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 n-ary

association.

9/7/1999 Information Organization and Retrieval

Associations: Unary relationships

PersonIs-married-to

0..1

0..1

Employeemanages

*

0..1 manager

9/7/1999 Information Organization and Retrieval

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* *

9/7/1999 Information Organization and Retrieval

Associations: Ternary Relationships

Vendor Warehouse* *Supplies

Part

*

9/7/1999 Information Organization and Retrieval

Association Classes

Student CourseRegisters-for

* *

Registration________________TermGrade________________CheckEligibility()

Computer Account_________________

acctIDPassword

ServerSpace* 0..1

issues

9/7/1999 Information Organization and Retrieval

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

9/7/1999 Information Organization and Retrieval

GeneralizationEmployee

____________empName

empNumberaddress

dateHired____________

printLabel()

Hourly Employee_______________

HourlyRate_______________computeWages()

Salaried Employee_______________

Annual Salstockoption

_______________Contributepension()

Consultant_______________contractNumber

billingRate_______________

computeFees()

9/7/1999 Information Organization and Retrieval

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

CampusAddress Building OfficeNumber

id DepartmentName

PhoneNumberFaxPhoneNumber

COLLEGE

PROFESSOR

STUDENT

1.1

1.1

1.1 0.1

1.N

0.1

1.1

1.N

1.N

9/7/1999 Information Organization and Retrieval

Object InstanceSchool of Information Management and SystemsSouth Hall202642-1464642-9980642-1465

642-5814

School of Information Management and Systems

LarsonHearst

Varian

SmithEtc...

Etc...

9/7/1999 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 and when replacements or additional equipment is needed

9/7/1999 Information Organization and Retrieval

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

9/7/1999 Information Organization and Retrieval

DIVEORDS DIVEORDSid OrderNoSaleDate

SHIPVIA

DESTINATION

DIVEITEMPaymentMethodCCNumberCCExpDateNoOfPeopleDepartDateReturnDateVacationCost

DIVECUST

9/7/1999 Information Organization and Retrieval

Assignment 1

• What are the answers?– Access examples

top related