2 December 2005
Introduction to Databases
Object and Object-Relational Databases
Prof. Beat Signer
Department of Computer ...
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 2May 16, 2014
Impedance Mismatch Revisited
 Combination ...
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 3May 16, 2014
Impedance Mismatch Revisited ...
 Note tha...
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 4May 16, 2014
Object Databases
 ODBMSs use the same data...
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 5May 16, 2014
Persistent Programming Languages
 Several ...
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 6May 16, 2014
Persistent Programming Languages ...
 pers...
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 7May 16, 2014
ObjectStore Example
 Persistence by reacha...
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 8May 16, 2014
ObjectStore Example ...
 Post processing
(...
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 9May 16, 2014
ODBMS History
 First generation ODBMS
 19...
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 10May 16, 2014
ODBMS History ...
 Second generation ODBM...
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 11May 16, 2014
ODBMS History ...
 Further developments
...
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 12May 16, 2014
The Object-Oriented Database Manifesto
 M...
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 13May 16, 2014
The Object-Oriented Database Manifesto ......
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 14May 16, 2014
The Object-Oriented Database Manifesto ......
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 15May 16, 2014
The Object-Oriented Database Manifesto ......
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 16May 16, 2014
The Object-Oriented Database Manifesto ......
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 17May 16, 2014
Object Data Management Group (ODMG)
 Obje...
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 18May 16, 2014
ODMG Object Model
 ODMG object model is b...
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 19May 16, 2014
Types
 Specification
 properties (attrib...
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 20May 16, 2014
Type Specifications
 Interface defines on...
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 21May 16, 2014
Objects
 Atomic objects
 user defined
 ...
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 22May 16, 2014
Literal Types
 Atomic literals
 long, lo...
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 23May 16, 2014
Relationship Example
 One-to-one, one-to-...
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 24May 16, 2014
Behaviour
 Behaviour is specified as a se...
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 25May 16, 2014
Inheritance of Behaviour
 A subtype may
...
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 26May 16, 2014
Inheritance of State and Behaviour
 Keywo...
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 27May 16, 2014
Object Definition Language (ODL) Example
A...
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 28May 16, 2014
ODL Example ...
module Education {
excepti...
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 29May 16, 2014
ODL Example ...
class Session (extent sess...
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 30May 16, 2014
ODL Example ...
interface StudentI {
attri...
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 31May 16, 2014
ODL Example ...
class Professor extends Em...
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 32May 16, 2014
Object Databases
 Many ODBMS also impleme...
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 33May 16, 2014
Object-Relational Mapping (ORM)
 "Automat...
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 34May 16, 2014
Object-Relational Databases
 The object-r...
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 35May 16, 2014
Object-Relational Databases ...
 Since SQ...
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 36May 16, 2014
Object vs. Object-Relational Databases
 O...
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 37May 16, 2014
Homework
 Study the following chapters of...
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 38May 16, 2014
Exercise 11
 Transaction Management
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 39May 16, 2014
References
 A. Silberschatz, H. Korth and...
2 December 2005
Next Lecture
Future Trends and Review
Upcoming SlideShare
Loading in...5
×

Object and Object-Relational Databases - Lecture 12 - Introduction to Databases (1007156ANR)

10,296
-1

Published on

This lecture is part of an Introduction to Databases course given at the Vrije Universiteit Brussel.

Published in: Education, Technology
0 Comments
7 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
10,296
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
539
Comments
0
Likes
7
Embeds 0
No embeds

No notes for slide

Object and Object-Relational Databases - Lecture 12 - Introduction to Databases (1007156ANR)

  1. 1. 2 December 2005 Introduction to Databases Object and Object-Relational Databases Prof. Beat Signer Department of Computer Science Vrije Universiteit Brussel http://www.beatsigner.com
  2. 2. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 2May 16, 2014 Impedance Mismatch Revisited  Combination of SQL with a host language  mix of declarative and procedural programming paradigms  two completely different data models  different set of data types  Interfacing with SQL is not straightforward  data has to be converted between host language and SQL due to the impedance mismatch  ~30% of the code and effort is used for this conversion!  The problem gets even worse if we would like to use an object-oriented host language  two approaches to deal with the problem - object databases (object-oriented databases) - object-relational databases
  3. 3. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 3May 16, 2014 Impedance Mismatch Revisited ...  Note that it would be easier to use the SQL AVG operator public float getAverageCDLength() { float result = 0.0; try { Connection conn = this.openConnection(); Statement s = conn.createStatement(); ResultSet set = s.executeQuery("SELECT length FROM CD"); int i = 0; while (set.next()) { result += set.getInt(1); i++; } return result/i; } catch (SQLException e) { System.out.println("Calculation of average length failed."); return 0; } }
  4. 4. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 4May 16, 2014 Object Databases  ODBMSs use the same data model as object-oriented programming languages  no object-relational impedance mismatch (due to uniform model)  An object database combines the features of an object- oriented language and a DBMS (language binding)  treat data as objects - object identity - attributes and methods - relationships between objects  extensible type hierarchy - inheritance, overloading and overriding as well as customised types  declarative query language
  5. 5. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 5May 16, 2014 Persistent Programming Languages  Several approaches have been proposed to make transient programming language objects persistent  persistence by class - declare that a class is persistent - all objects of a persistent class are persistent whereas objects of non-persistent classes are transient - not very flexible; we would like to have persistent and transient objects from a single class - many ODBMSs provide a mechanism to make classes persistence capable  persistence by creation - introduce new syntax to create persistent objects - object is either persistent or transient depending on how it was created  persistence by marking - mark objects as persistent after creation but before the program terminates
  6. 6. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 6May 16, 2014 Persistent Programming Languages ...  persistence by reachability - one or more objects are explicitly declared as persistent objects (root objects) - all the other objects are persistent if they are reachable from a root object via a sequence of one or more references - easy to make entire data structures persistent
  7. 7. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 7May 16, 2014 ObjectStore Example  Persistence by reachability via specific database roots  Persistence capable classes  post-processor makes specific classes persistent capable  Persistent aware classes  can access and manipulate persistent objects (not persistent)  Three states after a persistent object has been loaded  hollow: proxy with load on demand (lazy loading)  active: loaded in memory and flag set to clean  stale: no longer valid (e.g. after a commit) Person ariane = new Person("Ariane Peeters") db.createRoot("Persons", ariane);
  8. 8. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 8May 16, 2014 ObjectStore Example ...  Post processing (1) compile all source files (2) post-process the class files to generate annotated versions of the class files (3) run the post-processed main class javac *.java osjcfp –dest . –inplace *.class java mainClass
  9. 9. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 9May 16, 2014 ODBMS History  First generation ODBMS  1984 - George P. Copeland and David Maier, Making Smalltalk a Database System, SIGMOD 1984  1986 - G-Base (Graphael, F)  1987 - GemStone (Servio Corporation, USA)  1988 - Vbase (Ontologic) - Statice (Symbolics) David MaierGeorge P. Copeland
  10. 10. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 10May 16, 2014 ODBMS History ...  Second generation ODBMS  1989 - Ontos (Ontos) - ObjectStore (Object Design) - Objectivity (Objectivity) - Versant ODBMS (Versant Object Technology)  1989 - The Object-Oriented Database System Manifesto  Third generation ODBMS  1990 - Orion/Itasca (Microelectronis and Computer Technology Cooperation, USA) - O2 (Altaïr, F) - Zeitgeist (Texas Instruments)
  11. 11. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 11May 16, 2014 ODBMS History ...  Further developments  1991 - foundation of the Object Database Management Group (ODMG)  1993 - ODMG 1.0 standard  1996 - PJama (Persistent Java)  1997 - ODMG 2.0 standard  1999 - ODMG 3.0 standard  2001 - db4o (database for objects)  ...
  12. 12. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 12May 16, 2014 The Object-Oriented Database Manifesto  Malcolm Atkinson, François Bancilhon, David DeWitt, Klaus Dittrich, David Maier and Stanley Zdonik, The Object-Oriented Database System Manifesto, 1989 Malcolm Atkinson François Bancilhon David DeWitt Klaus Dittrich David Maier Stanley Zdonik
  13. 13. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 13May 16, 2014 The Object-Oriented Database Manifesto ...  The Object-Oriented Database System Manifesto by Atkinson et al. was an attemp to define object-oriented databases  defines 13 mandatory features that an object-oriented database system must have - 8 object-oriented system features - 5 DBMS features  optional features - multiple inheritance, type checking, versions, ...  open features - points where the designer can make a number of choices
  14. 14. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 14May 16, 2014 The Object-Oriented Database Manifesto ...  Object-oriented system features  complex objects - complex objects built from simple ones by constructors (e.g. set, tuple and list) - constructors must be orthogonal  object identity - two objects can be identical (same object) or equal (same value)  encapsulation - distinction between interface (public) and implementation (private)  types and classes - type defines common features of a set of objects - class as a container for objects of the same type  type and class hierarchies  overriding, overloading and late binding
  15. 15. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 15May 16, 2014 The Object-Oriented Database Manifesto ...  computational completeness - should be possible to express any computable function using the DML  extensibility - set of predefined types - no difference in usage of system and user-defined types  DBMS features  persistence - orthogonal persistence (persistence capability does not depend on the type)  secondary storage management - index management, data clustering, data buffering, access path selection and query optimisation  concurrency - atomicity, consistency, isolation and durability (ACID) - serialisability of operations
  16. 16. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 16May 16, 2014 The Object-Oriented Database Manifesto ...  recovery - in case of hardware or software failures, the system should recover  ad hoc query facility - high-level declarative query language  The OODBMS Manifesto lead to discussion and reactions from the RDBMS community  Third-Generation Database System Manifesto, Stonebraker et al.  The Third Manifesto, Darwen and Date  Issues not addressed in the manifesto  database evolution  constraints  object roles  ...
  17. 17. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 17May 16, 2014 Object Data Management Group (ODMG)  Object Database Management Group (ODMG) was founded in 1991 by Rick Cattel  standardisation body including all major ODBMS vendors  Defines a standard to increase the porta- bility accross different ODBMS products  Object Model  Object Definition Language (ODL)  Object Query Language (OQL)  language bindings - C++, Smalltalk and Java bindings Rick Cattell
  18. 18. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 18May 16, 2014 ODMG Object Model  ODMG object model is based on the OMG object model  Basic modelling primitives  object: unique identifier  literal: no identifier  An object's state is defined by the values it carries for a set of properties (attributes or relationships)  An object's behaviour is defined by the set of operations that can be executed  Objects and literals are categorised by their type (common properties and common behaviour)
  19. 19. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 19May 16, 2014 Types  Specification  properties (attributes and relationships)  operations  exceptions  Implementation  language binding  a specification can have more than one implementation
  20. 20. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 20May 16, 2014 Type Specifications  Interface defines only abstract behaviour  attribute declarations in an interface define only abstract behaviour (can be implemented as a method!)  Class defines abstract behaviour and abstract state  Literal defines abstract state
  21. 21. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 21May 16, 2014 Objects  Atomic objects  user defined  no built-in atomic object types  Collection objects  Set<t>  Bag<t>  List<t>  Array<t>  Dictionary<t,v>  Structured objects  Date, Interval, Time, Timestamp
  22. 22. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 22May 16, 2014 Literal Types  Atomic literals  long, long long, short, unsigned long, unsigned short, float, double, boolean, octet, char, string, enum  Collection literals  set<t>  bag<t>  list<t>  array<t>  dictionary<t,v>  Structured literals  date, interval, time, timestamp  user defined structures (struct)
  23. 23. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 23May 16, 2014 Relationship Example  One-to-one, one-to-many or many-to-many relationships with referential integrity maintained by the system class Assistant { ... relationship set<ExerciseGroup> leads inverse ExerciseGroup::isLeadBy; ... } class ExerciseGroup { ... relationship Assistant isLeadBy inverse Assistant::leads; ... }
  24. 24. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 24May 16, 2014 Behaviour  Behaviour is specified as a set of operation signatures  An operation signature defines  name of the operation  names and types of arguments  type of return value  names of exceptions
  25. 25. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 25May 16, 2014 Inheritance of Behaviour  A subtype may  define new behaviour in addition to the one defined in its supertypes  refine a supertype's behaviour interface Contact {...} interface Person : Contact {...} interface ETHPerson : Person {...}
  26. 26. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 26May 16, 2014 Inheritance of State and Behaviour  Keyword EXTENDS  A subclass inherits all the properties and behaviour of its superclass interface Contact {...} interface Student {...} class Person : Contact {...} class ETHPerson extends Person : Student {...}
  27. 27. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 27May 16, 2014 Object Definition Language (ODL) Example Assistant Professor Employee Salary Lecture Exercise Session Course StudentI Student teaches isTaughtBy leads isLeadBy hasPrerequisites isPrerequisiteFor attends isAttendedBy hasSessions isSessionOf one-to-one many-to-many one-to-many is-a extends
  28. 28. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 28May 16, 2014 ODL Example ... module Education { exception SessionFull{}; ... class Course (extent courses) { attribute name; relationship Department offeredBy inverse Department::offers; relationship list<Session> hasSessions inverse Session::isSessionOf; relationship set<Course> hasPrerequisites inverse Course::isPrerequisiteFor; relationship set<Course> isPrerequisiteFor inverese Course::hasPrerequisites; }; class Salary (extent salaries) { attribute float base; attribute float bonus; }; ... }
  29. 29. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 29May 16, 2014 ODL Example ... class Session (extent sessions) { attribute string number; relationship Course isSessionOf inverse Course::hasSessions; relationship set<Student> isAttendedBy inverse Student::attends; }; class Lecture extends Session (extent lectures) { relationship Professor isTaughtBy inverse Professor::teaches; }; class Exercise extends Session (extent exercises) { attribute unsigned short maxMembers; relationship Assistant isLeadBy inverse Assistant::leads; };
  30. 30. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 30May 16, 2014 ODL Example ... interface StudentI { attribute string name; attribute Address address; relationship set<Session> attends inverse Session::isAttendeBy; }; class Student : StudentI (extent students) { attribute Address address; relationship set<Session> attends inverse Session::isAttendedBy; }; class Employee (extent employees) { attribute string name attribute Salary salary; void hire(); void fire() raises (NoSuchEmployee); };
  31. 31. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 31May 16, 2014 ODL Example ... class Professor extends Employee (extent professors) { attribute enum Type{assistant, full, ordinary} rank; relationship worksFor inverse Department:hasProfessors; relationship set<Lectures> teaches inverse Session::isTaughtBy; }; class Assistant extends Employee : StudentI (extent assistants) { attribute Address address; relationship Exercise leads inverse Exercise::isLeadBy relationship set<Session> attends inverse Session::isAttendedBy; };
  32. 32. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 32May 16, 2014 Object Databases  Many ODBMS also implement a versioning mechanism  Many operations are performed by using a navigational rather than a declarative interface  following pointers  In addition, an object query language (OQL) can be used to retrieve objects in a declarative way  some systems (e.g. db4o) also support native queries  Faster access than RDBMS for many tasks  no join operations required  However, object databases lack a formal mathematical foundation!
  33. 33. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 33May 16, 2014 Object-Relational Mapping (ORM)  "Automatic" mapping of object-oriented model to relational database  developer has to deal less with persistence-related programming  Hibernate  mapping of Java types to SQL types  generates the required SQL statements behind the scene  standalone framework  Java Persistence API (JPA)  Enterprise Java Beans Standard 3.0  use annotations to define mapping  javax.persistence package
  34. 34. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 34May 16, 2014 Object-Relational Databases  The object-relational data model extends the relational data model  introduces complex data types  object-oriented features  extended version of SQL to deal with the richer type system  Complex data types  new collection types including multisets and arrays  attributes can no longer just contain atomic values (1NF) but also collections  nest and unnest operations for collection type attributes  ER concepts such as composite attributes or multivalued attributes can be directly represented in the object-relational data model
  35. 35. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 35May 16, 2014 Object-Relational Databases ...  Since SQL:1999 we can define user-defined types  Type inheritance can be used for inheriting attributes of user-defined types
  36. 36. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 36May 16, 2014 Object vs. Object-Relational Databases  Object databases  complex datatypes  tight integration with an object-oriented programming language (persistent programming language)  high performance  Object-relational databases  complex datatypes  powerful query languages  good protection of data from programming errors
  37. 37. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 37May 16, 2014 Homework  Study the following chapters of the Database System Concepts book  chapter 22 - sections 22.1-22.11 - Object-based Databases
  38. 38. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 38May 16, 2014 Exercise 11  Transaction Management
  39. 39. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 39May 16, 2014 References  A. Silberschatz, H. Korth and S. Sudarshan, Database System Concepts (Sixth Edition), McGraw-Hill, 2010  Malcolm Atkinson, François Bancilhon, David DeWitt, Klaus Dittrich, David Maier and Stanley Zdonik, The Object-Oriented Database System Manifesto, 1989
  40. 40. 2 December 2005 Next Lecture Future Trends and Review
  1. ¿Le ha llamado la atención una diapositiva en particular?

    Recortar diapositivas es una manera útil de recopilar información importante para consultarla más tarde.

×