Object-Oriented Database Management Systems

Download Report

Transcript Object-Oriented Database Management Systems

Murat KARAÖZ
26.3.2017
Murat KARAÖZ
1
Scope
 What is an “Object Database”?
 History
 Queries
 When / Where / Why ODMSs
26.3.2017
Murat KARAÖZ
2
What is an “Object Database”?
 Integration of database capabilities with object oriented
programming language capabilities.
 Object databases store objects rather than data such as integers,
strings or real numbers.
 The Object-Oriented Database System Manifesto
 It should be a DBMS
 It should be an object-oriented system
26.3.2017
Murat KARAÖZ
3
Object databases history
 1985 - The term "object-oriented database system" first appeared
around.
 1991 –The first standard, ODMG 1.0, was released in 1993.
 1995 - The OODBMS Manifesto, Malcolm Atkinson
 2001 - Final ODMG 3.0 standards released. [OQL]
 2004 - Advent of Open Source: db4o released as free, open
source ODBMS. [Native Queries]
26.3.2017
Murat KARAÖZ
4
How do we store data?
26.3.2017
Murat KARAÖZ
5
How do we store data?
26.3.2017
Murat KARAÖZ
6
Object Query Language (OQL)
 Declarative query language
 Not computationally complete
 Syntax based on SQL (select, from, where)
 Additional flexibility (queries with user defined operators and
types)
26.3.2017
Murat KARAÖZ
7
Object Query Language (OQL)
Sample query: “what are the names of the black products?”
Select distinct p.name
From products p
Where p.color = “black”
Valid in both SQL and OQL, but results are different.
26.3.2017
Murat KARAÖZ
8
Result of the query (SQL)
Original table
Product no
Name
Color
P1
Ford Mustang
Black
P2
Toyota Celica
Green
P3
Mercedes SLK
Black
Result
Name
- The statement queries a relational
database.
Ford Mustang
Mercedes SLK
=> Returns a table with rows.
26.3.2017
Murat KARAÖZ
9
Result of the query (OQL)
Original table
Product no
Name
Color
P1
Ford Mustang
Black
P2
Toyota Celica
Green
P3
Mercedes SLK
Black
Result
String
Ford Mustang
26.3.2017
- The statement queries a
object-oriented database
String
Mercedes SLK
Murat KARAÖZ
=> Returns a collection of
objects.
10
OQL vs SQL
 Queries look very similar in SQL and OQL, sometimes they
are the same.
 In fact, the results they give are very different.
 Query returns:
OQL
SQL
Object
Tuple
Collection of objects Table
26.3.2017
Murat KARAÖZ
11
Querying in db4o
 db4o supports 3 forms of querying:
 Query by Example (QBE)
 Native Queries (NQ)
 Simple Object Database Query API (SODA Query API)
26.3.2017
Murat KARAÖZ
12
The Basics – Person Class
 creating and storing
 querying
 updating
 deleting
person objects
26.3.2017
Murat KARAÖZ
13
Accessing a Database
ObjectContainer db = Db4o.openFile( "database path");
try {
// access db
}
finally {
db.close();
}
26.3.2017
Murat KARAÖZ
14
Creating and Storing Objects
 Create objects as usual and then make them persistent using the
set() method on the database.
Person p1 = new Person("Fred Bloggs", 35);
db.set(p1);
Person p2 = new Person("Mary Jones", 24);
db.set(p2);
26.3.2017
Murat KARAÖZ
15
Querying Objects (QBE approach)
// retrieve by age (null default for string)
Person p = new Person (null, 35);
ObjectSet<Person> result = db.get(p);
// retrieve by name (0 default for int)
Person p = new Person ("Mary Jones", 0);
ObjectSet<Person> result = db.get(p);
// retrieve all persons
Person p = new Person (null, 0);
ObjectSet<Person> result = db.get(p);
26.3.2017
Murat KARAÖZ
16
Updating Objects
 First retrieve object (or objects), then perform update and then
store.
// update age of person
// assumes single result to query
ObjectSet <Person> res = db.get (new Person ("Mary Jones", 0);
Person p = res.next();
p.setAge (40);
db.set (p);
26.3.2017
Murat KARAÖZ
17
Deleting Objects
 As with updating objects, objects must first be retrieved and
then deleted.
// delete Fred Bloggs from database
ObjectSet<Person> res = db.get (new Person("Fred Bloggs", 0);
Person p = res.next();
db.delete(p);
26.3.2017
Murat KARAÖZ
18
Object database relationships
26.3.2017
Murat KARAÖZ
19
Object database relationships
26.3.2017
Murat KARAÖZ
20
Object database relationships
26.3.2017
Murat KARAÖZ
21
Benefits of using an ODBMS
 When you use an ODBMS, the way you use your data is the way
you store it.
 If you are working with complex data, an ODBMS can give you
performance that is ten to a thousand times faster than an
RDBMS.
26.3.2017
Murat KARAÖZ
22
When should you use an ODBMS?
 Use an ODBMS when you have a business need for high
performance on complex data.
 Embedded DBMS Applications
 Team is Using Agile Techniques
 You're Programming in an OO Language
 Real-Time applications
 Data is Accessed by Navigation Rather Than Query
26.3.2017
Murat KARAÖZ
23
Data is Accessed by Navigation
Rather Than Query
26.3.2017
Murat KARAÖZ
24
Everyday uses of object databases
 Are you aware that when you;
 use your cell phone,
 book a hotel room or a flight,
 receive health care,
you might very well be interacting with an object database?
26.3.2017
Murat KARAÖZ
25
Barriers to using ODBMSs
 Lack of Familiarity: Most programmers understand RDBMSs.
Many do not understand ODBMSs.
 Inertia: It is easier to use what you know.
 Technology Fear: It is scary when you do not know what is
inside ODBMS technology.
 Business Fear: Most of the ODBMS vendors are small
companies. Is this risk worth the technological benefits?
26.3.2017
Murat KARAÖZ
26
Performance
Myth: ODBMSs are slow
No, they are not.
26.3.2017
Murat KARAÖZ
27
Will ODBMSs replace RDBMSs?
 Before we begin, we should acknowledge reality: RDBMS works
just fine.
 There are plenty of remarkably good applications out there that
have been running on relational databases for years.
 That is highly unlikely. It's difficult, if not impossible, to move
off databases. That would be unrealistic. Where you primarily
see ODBMSs is in new development.
26.3.2017
Murat KARAÖZ
28
Summary – Definition
 Object database = OO + DB
 The Object-Oriented Database System Manifesto
 It should be a DBMS
 It should be an object-oriented system
26.3.2017
Murat KARAÖZ
29
Summary – Storage
26.3.2017
Murat KARAÖZ
30
Summary – Queries
SQL and OQL
Query by Example (QBE)
Native Queries (NQ)
Simple Object Database
Query APIs
26.3.2017
Murat KARAÖZ
31
Summary – Relationships
26.3.2017
Murat KARAÖZ
32
Summary
 Object databases are a niche field within the broader DBMS
market dominated by relational database management systems
(RDBMS).
 Object databases have been considered since the early 1980s and
1990s but they have made little impact on mainstream
commercial data processing, though there is some usage in
specialized areas.
26.3.2017
Murat KARAÖZ
33
References
 http://www.service-architecture.com/index.html
 http://www.odbms.org/
 Object Database Tutorial, Rick Cattell, International Conference
on Object-Oriented Databases Zurich, 2009
 http://en.wikipedia.org/wiki/Object_database
 The OODBMS Manifesto
3/26/2017
Murat KARAÖZ
34
Questions?
Thanks for listening.
Murat KARAÖZ
26.3.2017
Murat KARAÖZ
35