ADB-Lecture10-ObjectOrientedDBMS
Download
Report
Transcript ADB-Lecture10-ObjectOrientedDBMS
Object-Oriented
DBMS
Lecture 10
1
Relational DBMS’ Shortcomings
Lengthy query execution for simple queries
due to joins
Lack of hierarchy, a student is a special kind of
person
Should know the interrelation of tables to write
queries
Impossible to write a complete program using
only query languages like SQL
2
Relational DBMS’ Shortcomings..
No support of ADT
To many Index files
The need for normalization to remove inconsistency…
Difficult to understand the relational representation
Difficult to represent updates, update operations do not
correspond to the real world update operations.
3
Advantages of OO DBMS
Closer to real world objects
Reduction of code
Increase of application programmer’s understanding capability
Reliability
Maintainability
Ability to store/retrieve objects
Objects can be of complex types
Hierarchical structure and inheritance
4
Advantages of OODBMS…
Support of complex Objects
Homogenization of heterogeneity
in media, system, and others by regarding everything as an
object, whereby the followings can be realized:
multimedia DBMS
multi database system
interoperability among resources
ex) OMG (Object Management Group)
Consistent information system
development can be possible
OOA + OOD + OOP + OODB
(Analysis)
(Design)
(Programming)
5
Advantages of OODBMS…
Exact representation
Exact database update operation
High performance
Others… Reuse of codes, …
6
DBMS Generation
OODBMS is the 3rd Generation DBMS
1G DBMS
1968 IMS … IBM product
known as the hierarchical DBMS
2G DBMS
1970 Relational data model by E.F.Codd
1980’s Relational DBMS products Ingres, DB2, Oracle, …
1990 … the number of newly installed relational DBMSs exceeded
those of the 1G DBMSs
7
DBMS Generation…
2.5 DBMS
Late `80s … Extended relational DBMS
Startburst, Postgres, UniSQL/X => Informix universal server,
Oracle V.8
3G DBMS
In 90’s .. Object-Oriented DBMS products
8
Major DBMS applications
Two Major DB Management Areas:
1. Business(or Traditional) database management area
business database management
Employee management
Sales management
Inventory management, …
1G DBMS : Network DBMS
Hierarchical DBMS
2G DBMS : Relational DBMS
1 real world object : 1 tuple of a relation
ex. an employee :
1 tuple of relation Employee
9
Major DBMS applications…
2. Non-business (or Advanced) database management area
Advanced database management Database management for
CAD
CASE
Multimedia
Information system
…
3G DBMS: Object-Oriented DBMS
10
Relational DBMS vs. OO DBMS
Support of complex objects
A relational approach :
(a) A sample module
(b) A structural analysis
Module
X1 11 A
X2 12 B
101
13
Connection
y
103
A
B
102
14
15
D Q
104
Y
IS-PART-OF
Element
IS-PART-OF
16
Terminal
Module 7
11
Why Object-Oriented DBMS?(4)
(c) A relational representation of the module
Module
Terminal
ModuleID ModuleName
7
Module 7
Element
ModuleID ElementID ModuleName
7
101
2 inp. XNOR
7
102
2 inp.NAND
7
103
2 inp.NAND
7
104
Latch
Connection
ModuleID CommectionID ConnName
7
11
X1
7
12
X2
7
13
7
14
7
15
y
7
16
Y
ModuleID CommectionID TermName I/O
101
11
A
I
101
12
B
I
101
13
XNOR(A,B) O
102
12
A
I
102
16
B
I
102
14
NAND(A,B) O
103
13
A
I
103
14
B
I
103
15
NAND(A,B) O
104
15
D
I
104
16
Q
O
Problems
a) A lot of tuples
b) Difficult to imagine the original object
c) (Display) Process is slow
12
Why Object-Oriented DBMS?(5)
An Object-Oriented Approach
Benefits
1) Natural Representation
2) Direct Manipulation
(a) Object-oriented representation of module7-concept
Element
Module
elementName
moduleNumber
moduleName
connectedLine
elementNumber
terminalName
terminalParts
terminalNumber
input/output
elementParts
connectionParts
Terminal
Connection
connectionName
connectNumber
(b) Object-oriented representation of module7-schema
13
Why Object-Oriented DBMS?(6)
XNOR
101
module7
7
NAND
102
X1
11
X2
12
A
01
input
B
02
input
(c) Object-oriented representation of Module7-instance
14
An Object-Oriented Approach
: ONTOS Notation
class Module: public Object {
private:
int priv_moduleNum;
char priv_moduleName;
Set priv_elementParts;
Set priv_connectionParts;
public:
Module(int moduleNum, char moduleName);
/ accessors /
Set elementParts() {return priv_elementParts;};
15
An Object-Oriented Approach
: ONTOS Notation…
void elementExchange(int elementNum1, int
elementNum2);
…
}
(a) Schema Definition of class Module
Module currentModule=new Module(7, “Module7”);
(b) Creation of Module7 in a C++ program
currentModule->elementExchange(101,102);
(C) Element exchange-an example
16
What is OODBMS?
Object-Oriented data model:
The data modeling concept is same among 1G, 2G and 3G data
modeling.
The data models are different.
There is a paradigm shift between the 1G & 2G data model and 3G
data model, i.e. object-oriented data model.
Unfortunately, there is no standard object-oriented data model.(but
recently, ODMG-93)
Most of the current object-oriented data models depend on either
the Smalltalk or the C++ object-orientation.
Therefore, it is necessary to understand the object-orientation
concepts given by those programming languages.
17
Some object modeling techniques
Rumbough Model: OMT (Object modeling technique)
Information Engineering model: IE/O by Dodd and Short
Booch model
Jacobson model: OOSE
UML: Unified Modeling Language by Jacobson+booch+Rumbough
18
What is Object-Orientation?
Basic concepts:
Object
Method
Message
Class
Instance
Inheritance
Encapsulation
Polymorphism
19
What is Object-Orientation?...
Object
Representation of a real world object.
As it is, natural, …
Encapsulation is done
Variables and methods (i.e. data and procedures) are encapsulated
Communication between objects is done by sending messages.
Object has object identity
Object identity is realized by assigning unique OIDs to database
objects. OID is different from TID in the relational DB
20
What is Object-Orientation?...
Class
A template for defining the methods and variable for a
particular type of objects
&
Repository of the particular type of objects
An object is an instance of a particular class
21
What is Object-Orientation?...
[Example]
Class Aircraft
Subclass Airplane
Subclass PropellerAirplane
Subclass JetAirplane
…
Subclass Boeing747
Subclass Helicopter
Subclass Glider
Subclass Balloon
IS-A relationship (Generalization)
Inheritance from a superclass to its subclass
22
is-associated-with (association)
customer
isa
wholesale
order
isa (specialization)
retail
is_part-of(aggregation)
item
23
What is Object-Orientation?...
Inheritance
A mechanism whereby classes can make use of the methods and
variables defined in all classes above them on their branch of the
class hierarchy.
Reduce of code
Differential Programming
Increase of application programmer’s
Understanding capability
Productivity
Reliability
Maintainability
....
24
What is Object-Orientation?...
Multiple Inheritance
A class can have any number of superclasses.
[Example]
Class VTOL (vertical takeoff and landing) Aircraft may have class
Airplane and class Helicopter as its superclasses.
Class WorkingStudent can be defined as the subclass of both class
Worker and class Student
Resolving the name conflicts is a problem
25
What is Object-Orientation?...
[Example]
Both classes Worker and Student have variable “income”
representing salary and scholarship, respectively.
How do you define variable “income” in class WorkingStudent?
Overriding
The name of a method or a variable that is lowest in the
class hierarchy takes precedence, overriding the more
general definitions further up the hierarchy.
26
What is Object-Orientation?...
Polymorphism
The ability for different objects to be able to respond to the
same message with their own unique behavior(operator
overloading)
[Example]
anAirplane fly
aHelicopter fly
aBird fly
…
anAudio display
aVideo display
aGraphic display
…
27
Some OO DBMSs
O2 Lecluse et al 1988
ObjectStore (Lamb et al 1991)object design
VersantVersant object technology
Gemstone Servio Corp.
Gemstone
ONTOS
Objectivity DB
Many OODB systems have been developed but vanished
soon after [Silberschatz 2006].
ODMG has defined standards for Persistent C++ and Java bu
t discontinued its activity at 2002
28
ODL (Object definition language)
Object-Oriented DBMS
ODL: Object description language
Ideas
Relations
Relational DBMS
E/R
The Database modeling and implementation
29
Object-Oriented DBMS
ODL
C++based OODBMS
C++ embedding
Abstract ODL
ODL Smalltlak
Smalltalk-based OODBMS
Embedding
The Database modeling and implementation
30
ODL definition of class
The keyword “interface” is used to define a class
Interface Movie {
attribute string title;
attribute integer year;
attribute integer length;
attribute enum film {color, blackandwhite} filmtype;
};
An object of type Movie could be:
(“Gone with the wind”, 1939,231, color)
31
ODL definition of class…
Interface Star {
attribute string name;
attribute Struct Addr
{string street, string city} address;
};
32
ODL definition of class…
Interface Movie {
attribute string title;
attribute integer year;
attribute integer length;
attribute enum film {color, blackandwhite} filmtype;
relationship Set<Star> stars inverse Star::StarredIn;
relationship Studio ownedBy inverse Studio::owns;
};
Interface Star {
attribute string name;
attribute Struct Addr
{string street, string city} address;
relationship Set<Movie> starredIn inverse Movie::stars;
};
Interface Studio {
attribute string name;
attribute string address;
relationship Set<Movie> owns
inverse Movie::ownedBy;
};
33
ODL..
Suppose we like to define a relation from Movie to star:
ralationship Set<star> stars; //stars is the relation name
(defined within the interface Movie; Movie has a set of Stars)
Inverse relation (from stars to Movie): in the Star interface
ralationship Set<Movie> starredIn; //starredIn is the relation name
Define a relation and its inverse
ralationship Set<Movie> starredIn InverseMovie::stars;
Subclass definition and hence inheritance
interface Cartoon: Movie{
ralationship Set<star> voices;
Multiple inheritance is possible, for example from cartoon and murder-mystry
interface cartoon-murder-mystry: cartoon, murder-mystry {};
Keys may be defined as:
interface Movie (Key(title,year)){….}
34
Subclass/Superclass
Consider Subclasses of Movie
Cartoon
Murder mysteries
Adventure
Comedies
Interface Cartoon : Movie {
relationship Set <Star> voices;
};
A subclass inherits all properties of its superclass
Hierarchy of subclass relationship is possible
Multiple inheritance:
Interface Cartoon-MurderMystery: Cartoon, MurderMystery{};
35
OQL
OQL: An extension on object-oriented language like smallt
alk, Java.
Some example: asking the year of the movie…
SELECT m.year
FROM Movies m
WHERE m.title=“Gone with the wind”
Asking names of stars of Casablanca
SELECT s.year
FROM Movies m, m.stars s
WHERE m.title=“Casablanca”
36
OQL…
Asking the names of movies of Disney (eliminate duplicate
s)
SELECT DISTINCT s.name
FROM Movies m, m.stars s
WHERE m.ownedBy.name=“Disney”
Asking the set of pairs of stars living at the same address.
By using s1.name<s2.name duplicate pairs are not
produced.
SELECT DISTINCT Struct(star1: s1, star2: s2)
FROM Stars s1, Stars s2
WHERE s1.addr = s2.addr AND s1.name < s2.name
37
OQL…
ORDER BY
FOR ALL x IN S : C(x)
EXISTS x in S :C(x)
AVG
GROUP BY
SUM
HAVING
UNION
INTERSWCT
EXCEPT
38
OQL…
Keys:
A set k of one or more attributes
No two objects can have the same key
Interface Movie
(key (title, year))
{
.
.
}:
39
OODB Implementation
OO Programming Languages +
Object Persistencey: Objects of an OO program (like variables of a
structured program) vanish as the program is completed. These
programming languages must be extended to handle persistent data.
There are several methods to do this.
Persistent by class: declare the class as persistent then all objects
of the class are persistent.
Persistent by creation: provide a syntax for introducing objects as
persistent. Some objects are transient while others are persistent.
Persistent by reachability: One or more objects are declared as
root persistent objects. All other objects are persistent iff they are
reachable from roots.
40
OODB Implementation…
Persistent pointers: must be able to define persistent pointers. Must
be able to fetch objects from disk and return an in-memory pointer.
Relationship: are represented by storing pointers from each object
to the objects that is related to. If b points to c then an automatic
pointer will be created from c to b.
Iterator interface: an interface is required to iterate over members
of a class
Transactions: Support of starting and ending transactions.
Updates: Updates to the database should be transparent. Therefore
same functions can be used to update objects regardless of whether
they are persistent or transient.
Query Languages: is needed
41
Disadvantages of OODBMS
No Standard
No query language
Too many object classes since each object can only be a m
ember of one object class
42
Integrity rules &Constraints
Candid Key: An attribute or a set of attributes which
u
niquely identifies objects
Attributes composing can. Key: May not be Null or default
values
Referential integrity:
if a pointer points to an object the object must exists
During deleting an object make sure no other object points to this
object
43