OBJECT DATABASES and An Advent Open Source : DB4O Gözde Özahi CEng553 / Fall 2008.

Slides:



Advertisements
Similar presentations
An Object/Relational Mapping tool Free and open source Simplifies storage of object data in a relational database Removes the need to write and maintain.
Advertisements

OO databases 1 Object Oriented databases. OO databases 2 Developing OODBMS - motivation motivation more and more application areas require systems that.
Chapter 10: Designing Databases
Object Oriented Database Group 4 Mathieu Metz Palani Kumaresan Napa Gavinlertvatana Kristine Pei Keow Lee Prabhu Ramachandran.
Jane Reid, BSc/IT DB, QMUL, 25/2/02 1 Object-oriented DBMS Background to ODBMS ODBMS requirements Object components ODB conceptual design –Graphical ODB.
Object Databases Baochuan Lu. outline Concepts for Object Databases Object Database Standards, Languages, and Design Object-Relational and Extended-Relational.
Database: A collection of related data [Elmasri]. A database represents some aspect of real world called “miniworld” [Elmasri] or “enterprise” [Ramakrishnan].
CS848: Topics in Databases: Foundations of Query Optimization Review  SQL the programming language  Applications in information systems  SQL technology.
ODMG Standard: Object Model1 OBJECT-ORIENTED DATABASE SYSTEMS ODMG Standard: Object Model Susan D. Urban and Suzanne W. Dietrich Department of Computer.
--What is a Database--1 What is a database What is a Database.
OBJECTS Object Oriented ???????. OBJECTS Object-Oriented n OO convenient label for a collection of interconnected ideas n OO approach views computer.
Introduction to Structured Query Language (SQL)
Concurrency and Transaction Management in an Object Oriented Database Initial Presentation Author: Jeremy Torres Date: 5/30/2003.
Chapter 11 Data Management Layer Design
McGraw-Hill/Irwin Copyright © 2007 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 18 Object Database Management Systems.
Object-Oriented Methods: Database Technology An introduction.
Databases Illuminated Chapter 7 The Object-Oriented Model.
RIZWAN REHMAN, CCS, DU. Advantages of ORDBMSs  The main advantages of extending the relational data model come from reuse and sharing.  Reuse comes.
Chapter 4 Object and Object-Relational Databases (Part ½: Object-Oriented Concepts) Lecturer: H.Ben Othmen Department of Computer Science, Umm Al-Qura.
OBJECT DATABASE CONCEPTS MIS 409 John Vance Cassidy Warren April 23, 2015.
EER vs. UML Terminology EER Diagram Entity Type Entity Attribute
INTRODUCTION TO TRANSACTION PROCESSING CHAPTER 21 (6/E) CHAPTER 17 (5/E)
Object Oriented Databases by Adam Stevenson. Object Databases Became commercially popular in mid 1990’s Became commercially popular in mid 1990’s You.
Object and object-relational databases 1. Object databases vs. Object-relational databases Object databases Stores complex objects – Data + functions.
Advanced Database CS-426 Week 2 – Logic Query Languages, Object Model.
Object Query Language OQL
REFACTORING Lecture 4. Definition Refactoring is a process of changing the internal structure of the program, not affecting its external behavior and.
DBSQL 10-1 Copyright © Genetic Computer School 2009 Chapter 10 Object-Oriented Based DBMS.
DBMS Lecture 9  Object Database Management Group –12 Rules for an OODBMS –Components of the ODMG standard  OODBMS Object Model Schema  OO Data Model.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor Ms. Arwa.
Module Title? DBMS Introduction to Database Management System.
Object Oriented Database By Liem Do And Jesslyn Bui.
1 CS 430 Database Theory Winter 2005 Lecture 1: Introduction.
ORDBS1 Object Relational Database Systems: 1. Introduction 2. Objects in SQL3 3. Comparison of ODL/OQL and SQL3 Approaches CIS 671.
1 INTRODUCTION TO DATABASE MANAGEMENT SYSTEM L E C T U R E
Object-Oriented Database Management Systems (ODBMS)
CODD’s 12 RULES OF RELATIONAL DATABASE
1 Chapter 10: Data Abstraction and Object Orientation Aaron Bloomfield CS 415 Fall 2005.
Modern Database Techniques Part 1: Object Oriented Databases 3. Different Kinds of OODB.
1 Object Databases: Introduction. 2 Why OO? v Relational Systems are limited: –Structural restrictions on data –Missing semantics (value-based relationships)
PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 4th Edition Copyright © 2009 John Wiley & Sons, Inc. All rights.
1 CS 430 Database Theory Winter 2005 Lecture 17: Objects, XML, and DBMSs.
1 The Relational Model. 2 Why Study the Relational Model? v Most widely used model. – Vendors: IBM, Informix, Microsoft, Oracle, Sybase, etc. v “Legacy.
Database Design and Management CPTG /23/2015Chapter 12 of 38 Functions of a Database Store data Store data School: student records, class schedules,
Chapter 18 Object Database Management Systems. McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Outline Motivation for object.
© 2002 by Prentice Hall 1 David M. Kroenke Database Processing Eighth Edition Chapter 18 Object- Oriented Database Processing.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
Object relational database managmement systems (ORDBMS) Adapted by Edel Sherratt from originals by Nigel Hardy.
1 CS457 Object-Oriented Databases Chapters as reference.
Creating and Maintaining Geographic Databases. Outline Definitions Characteristics of DBMS Types of database Relational model SQL Spatial databases.
OODBMS: Introduction and Logical Database Design
Object Oriented Database By Ashish Kaul References from Professor Lee’s presentations and the Web.
© D. Wong Security and User Authorization in SQL 8.7 pp. 410  Authorization ID = user name  Special authorization ID: PUBLIC  Privileges for:
AND OBJECT-ORIENTED DATABASES OBJECT-RELATIONAL DATABASES.
Lecture 10 Creating and Maintaining Geographic Databases Longley et al., Ch. 10, through section 10.4.
The ODMG Standard for Object Databases
Object storage and object interoperability
Svetoslav Kapralov. ContentsContents 1.DB4O Overview OODBMS vs. RDBMSOODBMS vs. RDBMS What is DB4OWhat is DB4O 2.DB4O Basics Object ContainerObject Container.
Chapter 18 Object Database Management Systems. Outline Motivation for object database management Object-oriented principles Architectures for object database.
The Object-Oriented Database System Manifesto Malcolm Atkinson, François Bancilhon, David deWitt, Klaus Dittrich, David Maier, Stanley Zdonik DOOD'89,
PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 5th Edition Copyright © 2015 John Wiley & Sons, Inc. All rights.
IST 210 Object Oriented Database. IST 210 Object-Oriented Concepts  Abstract Data Types  Class definition, provides extension to complex attribute types.
Faeez, Franz & Syamim.   Database – collection of persistent data  Database Management System (DBMS) – software system that supports creation, population,
CS422 Principles of Database Systems Object-Relational Mapping (ORM) Chengyu Sun California State University, Los Angeles.
Murat KARAÖZ1. Scope What is an “Object Database”? History Queries When / Where / Why ODMSs Murat KARAÖZ2.
CS 440 Database Management Systems Stored procedures & OR mapping 1.
OODBMS and ORDBMS. Background Object-oriented software, based on the principles of user-defined datatypes, along with inheritance and polymorphism, is.
1 Section 1 - Introduction to SQL u SQL is an abbreviation for Structured Query Language. u It is generally pronounced “Sequel” u SQL is a unified language.
Introduction to Data Structure
Presentation transcript:

OBJECT DATABASES and An Advent Open Source : DB4O Gözde Özahi CEng553 / Fall 2008

Introduction to ODBMS Short History  İn existence now for nearly 2 decades  started with accomodating OO languages like Smalltalk, C++ and Java  with commercial products shipping the mid 90’s  today used in large scale applications including telecommunication, banking, manufacturing, insurance, shipping.  for applications having complex data  good at storing complex data

Introduction to ODBMS Important milestones of history  Early 1980s – Orion Research Project at MCC  Late 1980s – First wave of commercial products  1991 – ODMG (with 5 major OODMS vendors)  1995 – OODMS Manifesto (Malcolm Atkinson)  2001 – Final ODMG 3.0 standards released  2004 – Advent of Open Source (db4o released as free)

What is ODBMS? Referred as object-oriented DBMS Modeling and creation of data as objects  Support for classes of objects  Inheritance of class properities and methods by subclasses ODBMS must satisfy two criteria (The OODBMS Manifesto)  should be a DBMS  should be an OO system

What is ODBMS? no standard for what consituted ODBMS no standard query language (as SQL in RDBMS) originally thought to replace RDBMS (for better fit with OO languages). high switching cost directed to ORDBMS now established as a complement, not a replacement to RDBMS

ODBMS vs. RDBMS An object database (ODBMS) stores objects directly An object database (ODBMS) stores objects directly

Reational Model Weaknesses Data Model  A single bulk data type (relation)  No direct support Hierarchies (part-of or is-a). Advanced data types (spatial, multimedia...) Programming  impedance mismatches due to query language emphasis  Challenging to make existing application data persist.

Object Databases Motivation:to overcome RDB Weaknesses  Richer data models  Closer integration with programming languages Kinds of ODBs  Object relational (Oracle, DB2, PostgreSQL).  Semantic data model(Jasmine).  Programming language centred (Objectivity, FastObjects, Versant, ObjectStore).

Object Database Standards SQL-99:  Mainstream SQL standard.  Oracle, DB2, Informix. Object data management group (ODMG):  Outgoing mainstream object database standard.  Objectivity, FastObjects, Versant. Java data objects (JDO):  Java-specific object-based database access.  Poet, Versant, ObjectStore, SolarMetric...

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)

Example of OQL query The following is a sample query “what are the names of the black colored product?” Select distinct p.name From products p Where p.color = “black”  Valid in both SQL and OQL, but results are different.

Result of the query (SQL) Original table Product noNameColor P1Ford MustangBlack P2Toyota CelicaGreen P3Mercedes SLKBlack Result Name Ford Mustang Mercedes SLK The statement queries a relational database. => Returns a table with rows.

Result of the query (OQL) Product noNameColor P1Ford MustangBlack P2Toyota CelicaGreen P3Mercedes SLKBlack - The statement queries an object- oriented database => Returns a collection of objects. String Ford Mustang Result Original table String Mercedes SLK

Comparison Queries look very similar in SQL and OQL, sometimes they are the same In fact, the results they give are very different Query returns: OQLSQL Object Collection of objects Tuple Table

ODBMS for RDBMS Users RDBMS vendors (IBM, Informix, Oracle.. Adding ORDBMS functionality) OODM architecture and user expectations get into mix While RDB architectures are very similar, OODB architectures vary considerably. Consider your application’s characteristics and find which OODB architecture is best suited

Structured Data Types SQL:1999 allow uses to define new data types, in additions to built-in data types (e.g. integers) SQL:1999 also introduced two type constructors Types defined by using type constructors are structured data types  ROW  base ARRAY

Operations On Structured Data Creating a “row type” Example: create row type AddressType( street char(50), citychar(20)); create row type StarType( name char(30), address AddressType);

Operations On Structured Data Creating “Table” create table Address of type AddressType; create table MovieStar of type StarType; Instances of Row types are tuples in tables

Operations On Structured Data(sample query ) Find the names and street addresses of those MovieStars who stay in the city “Ankara”: select MovieStar.name, MovieStar.address.street from MovieStar where MovieStar.address.city = “Ankara”;

When to use an ODBMS (some example conditions) Embedded DBMS Applications Complex Data (object) Relationships Deep object Structures Changing Data (object) Structures Usage of agile techniques in development team Programming in an OO Language Used objects in developemtn is including collections

Advent of Open Source: DB4O

What is db4o? Open source object database 1,000,000 downloads, 20,000 registered community members 200 customers smoothly integrates into an OO system cutting down on development time by skipping the costly object-relational mapping stays highly reliable and performant

DB4O Concepts Object Container Querying Transaction Object Identity Indexing Inheritance

Object Container simple and straightforward interface to object persistence – ObjectContainer ObjectContainer is your db4o database  Java: ObjectContainer container = Db4o.openFile(filename)  open an ObjectContainer when the application starts and close it, when the session is finished all the basic functionality to work with persistent objects  save a new or updated object of any class using ObjectContainer#set(object)  Deletion is done with => Java: container.delete(object)

Object Container - Storing Objects public static void storePilot() { new File(YAPFILENAME).delete(); ObjectContainer db=Db4o.openFile(YAPFILENAME); try { Pilot pilot=new Pilot("Michael Schumacher",0); db.set(pilot); System.out.println("Stored "+pilot); // change pilot and resave updated pilot.addPoints(10); db.set(pilot); System.out.println("Stored "+pilot); } finally { db.close(); }

Querying db4o supplies three querying systems  Query-By-Example (QBE),  Native Queries (NQ), and  the SODA Query API.

Querying - QBE you provide db4o with a template object. db4o will return all of the objects which match all non-default field values public static void retrievePilotByName(ObjectContainer db) { Pilot proto=new Pilot("Michael Schumacher",0); ObjectSet result=db.get(proto); listResult(result); }

Querying - QBE QBE has some obvious limitations:  db4o must reflect all members of your example object.  You cannot perform advanced query expressions. (AND, OR, NOT, etc.)  You cannot constrain on values like 0 (integers), "" (empty strings), or nulls (reference types) because they would be interpreted as unconstrained.  You need to be able to create objects without initialized fields. That means you can not initialize fields where they are declared. You can not enforce contracts that objects of a class are only allowed in a well-defined initialized state.  You need a constructor to create objects without initialized fields.

Querying - NQ main db4o query interface recommended way to query databases from your application  simply use the semantics of your programming language  perfectly standardized  safe choice for the future your provide the ability to run one or more lines of code against all instances of a class

Querying - NQ db4o will attempt to optimize native query expressions and run them against indexes public static void primitiveQuery(ObjectContainer db) { List pilots = db.query(new Predicate () { public boolean match(Pilot pilot) { return pilot.getPoints() == 100; } }); }

Querying – SODA Query API db4o's low level querying API allowing direct access to nodes of query graphs SODA uses strings to identify fields  Not perfectly typesafe  compile-time not checked  quite verbose to write For most applications Native Queries will be the better querying interfaceNative Queries

Querying – SODA Query API public static void retrieveAllPilots() { ObjectContainer db=Db4o.openFile(YAPFILENAME); try { Query query=db.query(); query.constrain(Pilot.class); ObjectSet result=query.execute(); listResult(result); } finally { db.close(); } how our familiar QBE queries are expressed with SODA

Transaction All work within db4o ObjectContainer is transactional implicitly started when you open a container the current transaction is implicitly committed when you close it again. ACID transaction model Data transaction journaling  zero data loss in case of system failure  automatic data recovery after system failure db4o core is thread-safe for simultaneous operations

Transaction – Commit choose to make a commit explicit or you may leave it for the #close() call public static void storeCarCommit(ObjectContainer db) { Pilot pilot=new Pilot("Rubens Barrichello",99); Car car=new Car("BMW"); car.setPilot(pilot); db.set(car); db.commit(); }

Transaction – Rollback do not want to save changes to the database, you can call rollback resetting the state of our database to the last commit point public static void storeCarRollback(ObjectContainer db) { Pilot pilot=new Pilot("Michael Schumacher",100); Car car=new Car("Ferrari"); car.setPilot(pilot); db.set(car); db.rollback(); }

Object Identity Db4o keeps references to all persistent objects whether they were retrieved, created or activated in this session The main role of the reference system  to provide access to the required data with the best speed  lowest memory consumption Performance and usability of the reference system depend much on how the system manages objects identities

Indexing Allows to index fields To request an index to be created by API method called in configuration file // assuming class Foo { String bar; } Db4o.configure().objectClass(Foo.class).objectField("bar").indexed(true); Once created will remain in database

Inheritance Subclasses and Inheritance with an example public class SensorReadout { private Date time; private Car car; private String description; /* * Suppose constructors and methods are here */ } public class TemratureSensorReadout extends SensorReadout {.... } public class PressureSensorReadout extends SensorReadout {.... }

Inheritance Suppose sensors are added to the database (two times) history.add(new TemperatureSensorReadout(new Date(), this, "oil", pollOilTemperature())); history.add(new TemperatureSensorReadout(new Date(), this, "water", pollWaterTemperature())); history.add(new PressureSensorReadout(new Date(), this, "oil", pollOilPressure())); retrieveTemperatureReadoutsQBE SensorReadout proto= new TemperatureSensorReadout(null,null,null,0.0); ObjectSet result=db.get(proto); listResult(result);

Inheritance Output: 4 BMW[Rubens Barrichello/99]/6 : Tue Jan 23 23:32:01 CET 2007 : oil temp : 0.0 BMW[Rubens Barrichello/99]/6 : Tue Jan 23 23:32:01 CET 2007 : water temp : 0.2 BMW[Rubens Barrichello/99]/6 : Tue Jan 23 23:32:01 CET 2007 : oil temp : BMW[Rubens Barrichello/99]/6 : Tue Jan 23 23:32:01 CET 2007 : water temp : 0.8

References Malcolm P. Atkinson, François Bancilhon, David J. DeWitt, Klaus R. Dittrich, David Maier, Stanley B. Zdonik: The Object-Oriented Database System Manifesto.The Object-Oriented Database System Manifesto Moira Norrie, Object Oriented Databases - Complete and up to date lecture series, ETH Zürich Moira Norrie db4o-6.0-tutorial.pdf Db4o Reference Guide