Slides from Lecture 25 - Courses - University of California, Berkeley
Download
Report
Transcript Slides from Lecture 25 - Courses - University of California, Berkeley
Object-Oriented Database
Development (Hoffer Chap 15)
University of California, Berkeley
School of Information Management
and Systems
SIMS 257: Database Management
IS 257 – Spring 2004
2004.04.22 - SLIDE 1
Lecture Outline
• Review
– Object Oriented DBMS
– Inverted File and Flat File DBMS
– Object-Relational DBMS (revisited)
– Intelligent DBMS
• Object Oriented Database Development
– Design using UML
– Construction with ODL
– Querying with OQL
IS 257 – Spring 2004
2004.04.22 - SLIDE 2
Lecture Outline
• Review
– Object Oriented DBMS
– Inverted File and Flat File DBMS
– Object-Relational DBMS (revisited)
– Intelligent DBMS
• Object Oriented Database Development
– Design using UML
– Construction with ODL
– Querying with OQL
IS 257 – Spring 2004
2004.04.22 - SLIDE 3
Object-Oriented DBMS Basic Concepts
• Each real-world entity is modeled by an
object. Each object is associated with a
unique identifier (sometimes call the object
ID or OID)
IS 257 – Spring 2004
2004.04.22 - SLIDE 4
Object-Oriented DBMS Basic Concepts
• Each object has a set of instance
attributes (or instance variables) and
methods.
– The value of an attribute can be an object or
set of objects. Thus complex object can be
constructed from aggregations of other
objects.
– The set of attributes of the object and the set
of methods represent the object structure and
behavior, respectively
IS 257 – Spring 2004
2004.04.22 - SLIDE 5
Object-Oriented DBMS Basic Concepts
• The attribute values of an object represent
the object’s status.
– Status is accessed or modified by sending
messages to the object to invoke the
corresponding methods
IS 257 – Spring 2004
2004.04.22 - SLIDE 6
Object-Oriented DBMS Basic Concepts
• Objects sharing the same structure and
behavior are grouped into classes.
– A class represents a template for a set of
similar objects.
– Each object is an instance of some class.
IS 257 – Spring 2004
2004.04.22 - SLIDE 7
Object-Oriented DBMS Basic Concepts
• A class can be defined as a specialization
of of one or more classes.
– A class defined as a specialization is called a
subclass and inherits attributes and methods
from its superclass(es).
IS 257 – Spring 2004
2004.04.22 - SLIDE 8
Object-Oriented DBMS Basic Concepts
• An OODBMS is a DBMS that directly
supports a model based on the objectoriented paradigm.
– Like any DBMS it must provide persistent
storage for objects and their descriptions
(schema).
– The system must also provide a language for
schema definition and and for manipulation of
objects and their schema
– It will usually include a query language,
indexing capabilities, etc.
IS 257 – Spring 2004
2004.04.22 - SLIDE 9
Generalization Hierarchy
employee
Employee No
Name
Address
Date hired
Date of Birth
calculateAge
Hourly
Salaried
consultant
Hourly Rate
Annual Salary
Stock Option
Contract No.
Date Hired
calculateWage
calculateStockBenefit
AllocateToContract
IS 257 – Spring 2004
2004.04.22 - SLIDE 10
Inverted File DBMS
• Usually similar to Hierarchic DBMS in
record structure
– Support for repeating groups of fields and
multiple value fields
• All access is via inverted file indexes to
DBS specified fields.
• Examples: ADABAS DBMS from Software
AG -- used in the MELVYL system
IS 257 – Spring 2004
2004.04.22 - SLIDE 11
Flat File DBMS
• Data is stored as a simple file of records.
– Records usually have a simple structure
• May support indexing of fields in the
records.
– May also support scanning of the data
• No mechanisms for relating data between
files.
• Usually easy to use and simple to set up
IS 257 – Spring 2004
2004.04.22 - SLIDE 12
Object Relational Data Model
• Class, instance, attribute, method, and
integrity constraints
• OID per instance
• Encapsulation
• Multiple inheritance hierarchy of classes
• Class references via OID object
references
• Set-Valued attributes
• Abstract Data Types
IS 257 – Spring 2004
2004.04.22 - SLIDE 13
PostgreSQL Classes
• The fundamental notion in Postgres is that of a
class, which is a named collection of object
instances. Each instance has the same
collection of named attributes, and each attribute
is of a specific type. Furthermore, each instance
has a permanent object identifier (OID) that is
unique throughout the installation. Because SQL
syntax refers to tables, we will use the terms
table and class interchangeably. Likewise, an
SQL row is an instance and SQL columns are
attributes.
IS 257 – Spring 2004
2004.04.22 - SLIDE 14
Creating a Class
• You can create a new class by specifying the
class name, along with all attribute names and
their types:
CREATE TABLE weather (
city
varchar(80),
temp_lo
int,
-- low temperature
temp_hi
int,
-- high temperature
prcp
real,
-- precipitation
date
date
);
IS 257 – Spring 2004
2004.04.22 - SLIDE 15
Intelligent Database Systems
• Intelligent DBS are intended to handle
more than just data, and may be used in
tasks involving large amounts of
information where analysis and “discovery”
are needed.
The following is based on “Intelligent Databases” by Kamran Parsaye,
Mark Chignell, Setrag Khoshafian and Harry Wong
AI Expert, March 1990, v. 5 no. 3. Pp 38-47
IS 257 – Spring 2004
2004.04.22 - SLIDE 16
Intelligent Database Systems
• They represent the evolution and merging
of several technologies:
– Automatic Information Discovery
– Hypermedia
– Object Orientation
– Expert Systems
– Conventional DBMS
IS 257 – Spring 2004
2004.04.22 - SLIDE 17
Intelligent Database Systems
Automatic
discovery
Expert
Systems
Intelligent
Databases
Hypermedia
Traditional
Databases
IS 257 – Spring 2004
Object
Orientation
2004.04.22 - SLIDE 18
Intelligent Databases
• Intelligent Database Engine
–
–
–
–
–
–
–
–
–
OO support
Inference features
Global optimization
Rule manager
Explanation manager
Transaction manager
Metadata manager
Access module
Multimedia manager
IS 257 – Spring 2004
2004.04.22 - SLIDE 19
Lecture Outline
• Review
– Object Oriented DBMS
– Inverted File and Flat File DBMS
– Object-Relational DBMS (revisited)
– Intelligent DBMS
• Object Oriented Database Development
– Construction with ODL
– Design using UML
– Querying with OQL
IS 257 – Spring 2004
2004.04.22 - SLIDE 20
Chapter 15:
Object-Oriented Database
Development
Modern Database Management
6th Edition
Jeffrey A. Hoffer, Mary B. Prescott, Fred
R. McFadden
This Lecture uses the slides following from www.prenhall.com/hoffer
IS 257 – Spring 2004
2004.04.22 - SLIDE 21
Object Definition Language (ODL)
• Corresponds to SQL’s DDL (Data
Definition Language)
• Specify the logical schema for an
object-oriented database
• Based on the specifications of Object
Database Management Group
(ODMG)
IS 257 – Spring 2004
2004.04.22 - SLIDE 22
Defining a Class
• class – keyword for defining classes
• attribute – keyword for attributes
• operations – return type, name,
parameters in parentheses
• relationship – keyword for
establishing relationship
IS 257 – Spring 2004
2004.04.22 - SLIDE 23
Defining an Attribute
• Value can be either:
– Object identifier OR Literal
• Types of literals
– Atomic – a constant that cannot be decomposed into
components
– Collection – multiple literals or object types
– Structure – a fixed number of named elements, each
of which could be a literal or object type
• Attribute ranges
– Allowable values for an attribute
– enum – for enumerating the allowable values
IS 257 – Spring 2004
2004.04.22 - SLIDE 24
Kinds of Collections
• Set – unordered collection without
duplicates
• Bag – unordered collection that may
contain duplicates
• List – ordered collection, all the same type
• Array – dynamically sized ordered
collection, locatable by position
• Dictionary – unordered sequence of keyvalue pairs without duplicates
IS 257 – Spring 2004
2004.04.22 - SLIDE 25
Defining Structures
Structure = user-defined type with
components
struct keyword
Example:
struct Address {
String street_address
String city;
String state;
String zip;
};
IS 257 – Spring 2004
2004.04.22 - SLIDE 26
Defining Operations
•
•
•
•
Return type
Name
Parentheses following the name
Arguments within the parentheses
IS 257 – Spring 2004
2004.04.22 - SLIDE 27
Defining Relationships
• Only unary and binary relationships allowed
• Relationships are bi-directional
– implemented through use of inverse keyword
• ODL relationships are specified:
– relationship indicates that class is on many-side
– relationship set indicates that class is on one-side
and other class (many) instances unordered
– relationship list indicates that class is on one-side
and other class (many) instances ordered
IS 257 – Spring 2004
2004.04.22 - SLIDE 28
Figure 15-1 –UML class diagram for a university database
The following slides illustrate the
ODL implementation of this
UML diagram
IS 257 – Spring 2004
2004.04.22 - SLIDE 29
Figure 15-2 –ODL Schema for university database
IS 257 – Spring 2004
2004.04.22 - SLIDE 30
Figure 15-2 –ODL Schema for university database
class keyword begins
the class
definition.Class
components enclosed
between { and }
IS 257 – Spring 2004
2004.04.22 - SLIDE 31
Figure 15-2 – ODL Schema for university database
attribute has a data type and a name
specify allowable values
using enum
IS 257 – Spring 2004
2004.04.22 - SLIDE 32
Figure 15-2 –ODL Schema for university database
extent = the set of all instances of the class
IS 257 – Spring 2004
2004.04.22 - SLIDE 33
Figure 15-2 –ODL Schema for university database
Operation definition:
return type, name,
and argument list.
Arguments include
data types and names
IS 257 – Spring 2004
2004.04.22 - SLIDE 34
Figure 15-2 –ODL Schema for university database
relationship sets indicate 1:N relationship to an
unordered collection of instances of the other class
inverse establishes the bidirectionality of the relationship
IS 257 – Spring 2004
2004.04.22 - SLIDE 35
Figure 15-2 –ODL Schema for university database
relationship list indicates 1:N relationship to an
ordered collection of instances of the other class
IS 257 – Spring 2004
2004.04.22 - SLIDE 36
Figure 15-2 –ODL Schema for university database
relationship indicates N:1 relationship to an
instance of the other class
IS 257 – Spring 2004
2004.04.22 - SLIDE 37
Figure 15-3 – UML class diagram for an employee project database
(a) Many-to-many relationship with an association class
Note:
In order to
capture special
features of
assignment, this
should be
converted into
two 1:N
relationships
IS 257 – Spring 2004
2004.04.22 - SLIDE 38
Figure 15-3 – UML class diagram for an employee project database
(b) Many-to many relationship broken into two one-to-many relationships
class Employee {
Note:
(extent employees
key indicates indentifier
key emp_id)
(candidate key)
………….
Note: attribute set indicates a
attribute set (string) skills_required;
multivalued attribute
};
IS 257 – Spring 2004
2004.04.22 - SLIDE 39
Figure 15-4
UML class diagram showing employee generalization
class Employee
extends Employee{
( ………….
………….
Note:
}
extends
denotes
subclassing
IS 257 – Spring 2004
2004.04.22 - SLIDE 40
Figure 15-5 –UML class diagram showing student generalization
Note: abstract class denotes noninstantiable (complete constraint)
abstract class Student
extends Employee{
( ………….
abstract float calc_tuition();
}
Note: abstract operation denotes no
method (no implementation) of
calc_tuition at the Student level
IS 257 – Spring 2004
2004.04.22 - SLIDE 41
Creating Object Instances
• Specify a tag that will be the object identifier
– MBA699 course ();
• Initializing attributes:
– Cheryl student (name: “Cheryl Davis”,
dateOfBirth:4/5/77);
• Initializing multivalued attributes:
– Dan employee (emp_id: 3678, name: “Dan Bellon”,
skills {“Database design”, “OO
Modeling”});
• Establishing links for relationship
– Cheryl student (takes: {OOAD99F, Telecom99F,
Java99F});
IS 257 – Spring 2004
2004.04.22 - SLIDE 42
Querying Objects in the OODB
•
•
•
•
Object Query Language (OQL)
ODMG standard language
Similar to SQL-92
Some differences:
– Joins use class’s relationship name:
• Select x.enrollment from courseofferings x,
x.belongs_to y where y.crse_course = “MBA 664”
and x.section = 1;
– Using a set in a query
• Select emp_id, name from employees where
“Database Design” in skills;
IS 257 – Spring 2004
2004.04.22 - SLIDE 43
Current ODBMS Products
• Rising popularity due to:
–
–
–
–
–
CAD/CAM applications
Geographic information systems
Multimedia
Web-based applications
Increasingly complex data types
• Applications of ODBMS
–
–
–
–
–
Bill-of-material
Telecommunications navigation
Health care
Engineering design
Finance and trading
IS 257 – Spring 2004
2004.04.22 - SLIDE 44
Table15-1 – ODBMS Products
IS 257 – Spring 2004
2004.04.22 - SLIDE 45