Chair of Software Engineering ATOT - Lecture 13, 14 May 2003 1 Advanced Topics in Object Technology Bertrand Meyer.

Slides:



Advertisements
Similar presentations
OO databases 1 Object Oriented databases. OO databases 2 Developing OODBMS - motivation motivation more and more application areas require systems that.
Advertisements

Chapter 10: Designing Databases
7/30/02 dbh0201 Recoverable Storable Facility 1 The Recoverable Storable Facility A Mismatch Correction Mechanism for Handling Schema Evolution in an Eiffel.
OBJECTS Object Oriented ???????. OBJECTS Object-Oriented n OO convenient label for a collection of interconnected ideas n OO approach views computer.
Chair of Software Engineering OOSC - Summer Semester Object-Oriented Software Construction Bertrand Meyer.
1 Database Systems (Part I) Introduction to Databases I Overview  Objectives of this lecture.  History and Evolution of Databases.  Basic Terms in Database.
11 3 / 12 CHAPTER Databases MIS105 Lec14 Irfan Ahmed Ilyas.
Introduction to Databases
Data Management I DBMS Relational Systems. Overview u Introduction u DBMS –components –types u Relational Model –characteristics –implementation u Physical.
©Silberschatz, Korth and Sudarshan1.1Database System Concepts Chapter 1: Introduction Purpose of Database Systems View of Data Data Models Data Definition.
Chair of Software Engineering ATOT - Lecture 25, 30 June Advanced Topics in Object Technology Bertrand Meyer.
Introduction to Databases Transparencies
1 Lecture 31 Introduction to Databases I Overview  Objectives of this lecture  History and Evolution of Databases  Basic Terms in Database and definitions.
Chair of Software Engineering Object-Oriented Software Construction Bertrand Meyer Lecture 16: Object Persistence Stephanie Balzer.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 4-1.
Object Oriented Databases - Overview
Object-Oriented Methods: Database Technology An introduction.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 1- 1.
Chapter 1 Introduction to Databases
Information systems and databases Database information systems Read the textbook: Chapter 2: Information systems and databases FOR MORE INFO...
Chapter 4 Object and Object-Relational Databases (Part ½: Object-Oriented Concepts) Lecturer: H.Ben Othmen Department of Computer Science, Umm Al-Qura.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education 4-1.
Chapter 1 Database and Database Users Dr. Bernard Chen Ph.D. University of Central Arkansas.
Introduction to Databases Transparencies 1. ©Pearson Education 2009 Objectives Common uses of database systems. Meaning of the term database. Meaning.
Introduction To Databases IDIA 618 Fall 2014 Bridget M. Blodgett.
Introduction to Databases and Database Languages
Introduction to DBMS Purpose of Database Systems View of Data
Database System Concepts and Architecture Lecture # 3 22 June 2012 National University of Computer and Emerging Sciences.
CS462: Introduction to Database Systems. ©Silberschatz, Korth and Sudarshan1.2Database System Concepts Course Information Instructor  Kyoung-Don (KD)
CSC2012 Database Technology & CSC2513 Database Systems.
DBMS Lecture 9  Object Database Management Group –12 Rules for an OODBMS –Components of the ODMG standard  OODBMS Object Model Schema  OO Data Model.
CS370 Spring 2007 CS 370 Database Systems Lecture 2 Overview of Database Systems.
 Introduction Introduction  Purpose of Database SystemsPurpose of Database Systems  Levels of Abstraction Levels of Abstraction  Instances and Schemas.
Introduction. 
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
Database and Database Users. Outline Database Introduction An Example Characteristics of the Database Actors on the Scene Advantages of using the DBMS.
CST203-2 Database Management Systems Lecture 2. One Tier Architecture Eg: In this scenario, a workgroup database is stored in a shared location on a single.
Database System Concepts and Architecture
Introduction: Databases and Database Users
Introduction to Database Systems
CODD’s 12 RULES OF RELATIONAL DATABASE
1 CS 430 Database Theory Winter 2005 Lecture 17: Objects, XML, and DBMSs.
Lecture2: Database Environment Prepared by L. Nouf Almujally & Aisha AlArfaj 1 Ref. Chapter2 College of Computer and Information Sciences - Information.
©Silberschatz, Korth and Sudarshan1.1Database System Concepts Chapter 1: Introduction Purpose of Database Systems View of Data Data Models Data Definition.
Lecture2: Database Environment Prepared by L. Nouf Almujally 1 Ref. Chapter2 Lecture2.
Lecture # 3 & 4 Chapter # 2 Database System Concepts and Architecture Muhammad Emran Database Systems 1.
5 - 1 Copyright © 2006, The McGraw-Hill Companies, Inc. All rights reserved.
CS370 Spring 2007 CS 370 Database Systems Lecture 1 Overview of Database Systems.
Lesson Overview 3.1 Components of the DBMS 3.1 Components of the DBMS 3.2 Components of The Database Application 3.2 Components of The Database Application.
Introduction to Database Systems1. 2 Basic Definitions Mini-world Some part of the real world about which data is stored in a database. Data Known facts.
1 CS 430 Database Theory Winter 2005 Lecture 2: General Concepts.
Database Environment Chapter 2. Data Independence Sometimes the way data are physically organized depends on the requirements of the application. Result:
1 CS457 Object-Oriented Databases Chapters as reference.
E.Bertino, L.Matino Object-Oriented Database Systems 1 Chapter 5. Evolution Seoul National University Department of Computer Engineering OOPSLA Lab.
1-1 Chapter 1 Databases and Database Users 1.1 Introduction 1.2 An Example 1.3 Characteristics of the Database Approach 1.4 Actors on the Scene 1.5 Workers.
INTRODUCTION TO DBS Database: a collection of data describing the activities of one or more related organizations DBMS: software designed to assist in.
CIS/SUSL1 Fundamentals of DBMS S.V. Priyan Head/Department of Computing & Information Systems.
1 Chapter 1 Introduction to Databases Transparencies.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Database System Concepts and Architecture.
Copyright (c) 2014 Pearson Education, Inc. Introduction to DBMS.
CHAPTER 9 File Storage Shared Preferences SQLite.
1 Lecture1 Introduction to Databases Systems Database 1.
Completeness Criteria for Object- Relational Database Systems by Won Kim April 2002 Sang Ho Lee School of Computing, Soongsil University
Data Resource Management Data Concepts Database Management Types of Databases Chapter 5 McGraw-Hill/Irwin Copyright © 2007 by The McGraw-Hill Companies,
Design by Contract Jim Fawcett CSE784 – Software Studio
Design by Contract Jim Fawcett CSE784 – Software Studio
Introduction To Database IT-402
Database Management:.
Database Management System
Introduction to Database Management System
Presentation transcript:

Chair of Software Engineering ATOT - Lecture 13, 14 May Advanced Topics in Object Technology Bertrand Meyer

Chair of Software Engineering ATOT - Lecture 13, 14 May Lecture 13: Object Persistence By Susanne Cech

Chair of Software Engineering ATOT - Lecture 13, 14 May Object persistence  During execution of application: objects are created and manipulated  What happens to objects after termination?  Various kinds of objects  Transient objects:  Disappear with current session  Persistent objects:  Stay around from session to session  May be shared with other applications (e.g. databases)

Chair of Software Engineering ATOT - Lecture 13, 14 May Approaches to manipulate persistent objects  Persistence mechanisms from programming languages  Relational databases  Object-oriented databases

Chair of Software Engineering ATOT - Lecture 13, 14 May Agenda for today  Persistence from programming languages  Advanced topics:  Beyond persistence closure  Schema evolution  From persistence to databases  Commercials

Chair of Software Engineering ATOT - Lecture 13, 14 May Agenda for today  Persistence from programming languages  Advanced topics:  Beyond persistence closure  Schema evolution  From persistence to databases  Commercials

Chair of Software Engineering ATOT - Lecture 13, 14 May Persistence from programming languages  Mechanisms for storing objects in files and retrieving them  Simple objects:  e.g. integers, characters  conventional methods usable  Composite objects:  contain references to other objects  Persistence Closure principle:  Any storage and retrieval mechanism must handle the object and all its dependents.  otherwise: dangling references

Chair of Software Engineering ATOT - Lecture 13, 14 May Dependents of an object  Direct dependents of an object:  Objects attached to its reference fields, if any  Dependents of an object:  Object itself and dependents of its direct dependents

Chair of Software Engineering ATOT - Lecture 13, 14 May name “Regula” Example: Persistence closure class TREE class PERSON feature -- Access item: PERSON name: STRING tree: TREE object left: TREE age: INTEGER OT*: TREE objects right: TREE best_friend: PERSON OP*: PERSON objects end item left right item left right age 24 best_friend name “Urs” age 18 best_friend name “Reto” age 29 best_friend tree OT1 OP1 OT2OP2 OP3 item left right OT3

Chair of Software Engineering ATOT - Lecture 13, 14 May Example from EiffelBase: the class STORABLE class interface STORABLE feature -- Access retrieve_by_name (file_name: STRING): ANY retrieved (medium: IO_MEDIUM): ANY feature -- Element change basic_store (medium: IO_MEDIUM) general_store (medium: IO_MEDIUM) independent_store (medium: IO_MEDIUM) store_by_name (file_name: STRING) end

Chair of Software Engineering ATOT - Lecture 13, 14 May STORABLE: Format variants  basic store (medium: IO_MEDIUM)  Retrievable within current system only  Most compact form possible  general store (medium: IO_MEDIUM)  Retrievable from other systems for same platform  independent store (medium: IO_MEDIUM)  Retrievable from other systems for the same or other platform  Portable data representation  Basic information about classes in the system  Independent of store-variant — always same retrieved

Chair of Software Engineering ATOT - Lecture 13, 14 May What is storable? IO_MEDIUM FILE * RAW_FILE + PLAIN_TEXT_FILE + CONSOLE * + Interfaced Deferred Effected Inheritance link

Chair of Software Engineering ATOT - Lecture 13, 14 May STORABLE: Example class PERSISTENT_TREE inherit STORABLE end class APPLICATION feature -- Initialization make is -- Create tree. do create tree.make end feature -- Access File_name: STRING is “out.dat” feature {NONE} -- Implementation tree: PERSISTENT_TREE feature -- Storage store_tree is -- Store tree to file. do tree.store_by_name (file_name) end feature -- Retrieval restore_tree is -- Retrieve tree from file. do tree ?= tree.retrieved (file_name) if tree /= Void then -- Something end invariant tree_not_void: tree /= Void end

Chair of Software Engineering ATOT - Lecture 13, 14 May Agenda for today  Persistence from programming languages  Advanced topics:  Beyond persistence closure  Schema evolution  From persistence to databases  Commercials

Chair of Software Engineering ATOT - Lecture 13, 14 May Beyond persistence closure class MOVIE_DESCRIPTION feature -- Access title: STRING director: STRING category: STRING release_date: DATE movie_file: MOVIE_FILE cast: LINKED_LIST [ACTOR] end class ACTOR feature -- Access name: STRING tel: STRING end O1: MOVIE_DESCRIPTION object OL*: LIST_ITEM objects OA*: ACTOR objects title “Office Space” director “Mike Judge” O1 category “Comedy” release_date “ ” movie_file cast next prev item OL1 next prev item OL2 name “Ron Livingston” OA1 tel “01/234912” … name “Jennifer Aniston” OA2 tel “034/ ” … x movie file (“BLOB”)

Chair of Software Engineering ATOT - Lecture 13, 14 May Beyond persistence closure class MOVIE_DESCRIPTION feature -- Access title: STRING director: STRING category: STRING release_date: DATE movie_file: MOVIE_FILE cast: LINKED_LIST [ACTOR] end class ACTOR feature -- Access name: STRING tel: STRING end O1: MOVIE_DESCRIPTION object OL*: LIST_ITEM objects OA*: ACTOR objects title “Office Space” director “Mike Judge” O1 category “Comedy” release_date “ ” movie_file cast next prev item OL1 next prev item OL2 name “Ron Livingston” OA1 tel “01/234912” … name “Jennifer Aniston” OA2 tel “034/ ” … x movie file (“BLOB”)

Chair of Software Engineering ATOT - Lecture 13, 14 May What to do?  “Cut out” the references of the shared structure  At retrieval time, objects need to be consistent!  Do not want to modify the original structure  The references should be cut out only in the stored structure

Chair of Software Engineering ATOT - Lecture 13, 14 May A customized class STORABLE class CUSTOMIZED_STORABLE inherit STORABLE feature -- Storage custom_store (medium: IO_MEDIUM) is -- Produce on medium an external -- representation of the entire object -- structure reachable from current -- object. do pre_store independent_store (medium) post_store end pre_store is -- Execute just before object is stored. deferred end post_store is -- Execute just after object is stored. deferred end feature -- Retrieval custom_retrieved (medium: IO_MEDIUM): ANY is -- Retrieved object structure, from external -- representation previously stored in medium do Result := retrieved (medium) post_retrieve end post_retrieve is -- Execute just before retrieved objects rejoin -- the community of approved objects. deferred end feature -- Storage (other solution) store_ignore (field_names: LINKED_LIST [STRING]) is -- Store skipping the fields given by field_names. do -- Not yet implemented. end

Chair of Software Engineering ATOT - Lecture 13, 14 May A customized class STORABLE (cont’d)  pre_store stores the reference to the object somewhere safe; sets the reference to Void  post_store retrieves the object again  pre_store must not perform any change of the data structure unless post_store corrects it immediately after  post_retrieve will perform the necessary actions to correct any inconsistencies introduced by pre_store (often the same as post_store)  store_ignore may simply skip the field  avoids the two-copy of pre_store/post_store  more efficient

Chair of Software Engineering ATOT - Lecture 13, 14 May Schema evolution  Fact: Classes change  Problem: Objects are stored of which class descriptions have changed  Schema evolution:  At least one class used by the retrieving system differs from its counterpart stored by the storing system.  Object retrieval mismatch:  The retrieving system retrieves a particular object whose own generating class was different in the storing system.  consequence for one particular object  No fully satisfactory solution

Chair of Software Engineering ATOT - Lecture 13, 14 May Different approaches  Naive, extreme approaches:  Forsake previously stored objects  Over a migration path from old format to new  one-time conversion of old objects  not applicable to a large persistent store or to one that must be available continuously  Most general solution: On-the-fly conversion  Note: We cover only the retrieval part. Whether to write back the converted object is a separate issue.

Chair of Software Engineering ATOT - Lecture 13, 14 May On-the-fly object conversion  Three separate issues:  Detection:  Catch object mismatch  Notification:  Make retrieving system aware of object mismatch  Correction:  Bring mismatched object to a consistent state  Make it a correct instance of the new class version

Chair of Software Engineering ATOT - Lecture 13, 14 May Detection  Detect a mismatch between two versions of an object’s generating class  Two categories of detection policy:  Nominal approach:  Each class version has a version name  Central registration mechanism necessary  Structural approach:  Deduce class descriptor from actual class structure  Store class descriptor  Simple detection: compare class descriptors of retrieved object with new class descriptor

Chair of Software Engineering ATOT - Lecture 13, 14 May Detection: Structural Approach  What does the class descriptor need to contain?  Trade-off between efficiency and reliability  Two extreme approaches:  C1: class name  C2: entire class text (e.g. abstract syntax tree)  Reasonable approaches:  C3: class name, list of attributes (name and type)  C4: in addition to C3: class invariant

Chair of Software Engineering ATOT - Lecture 13, 14 May Notification  What happens when the detection mechanism has caught an object mismatch?  Class ANY could include a procedure: correct_mismatch is -- Handle object retrieval mismatch. local exception: EXCEPTIONS do create exception exception.raise (‘‘[ Routine failure: Object mismatch during retrieval ]’’) end

Chair of Software Engineering ATOT - Lecture 13, 14 May Correction  How do we correct an object that caused a mismatch?  Current situation:  Retrieval mechanism has created a new object (deduced from a stored object with same generating class)  A mismatch has been detected  new object is in temporary (maybe inconsistent) state 0.0 Attribute was not in stored version. Field is initialized to default value of attribute type Stored version had a field. New version has removed attribute. Attributes have not changed.

Chair of Software Engineering ATOT - Lecture 13, 14 May Correction correct_mismatch is -- Handle object retrieval mismatch -- by correctly setting up balance. do balance := deposits.total - withdrawals.total ensure consistent: balance = deposits.total - withdrawals.total end deposits withdrawals balance new field (initialized to default value) old fields Wrong!

Chair of Software Engineering ATOT - Lecture 13, 14 May STORABLE: Limitations  Only the head object is known individually  Desirable to retain identity of other objects as well  Objects not selectively retrievable through contents-based or keyboard-based queries as in DBMS  Call retrieves the entire object structure  Cannot use two or more such calls to retrieve various parts of a structure, unless they are disjoint  No schema evolution  No simultaneous access for different client applications

Chair of Software Engineering ATOT - Lecture 13, 14 May Agenda for today  Persistence from programming languages  Advanced topics:  Beyond persistence closure  Schema evolution  From persistence to databases  Commercials

Chair of Software Engineering ATOT - Lecture 13, 14 May From persistence to databases  A set of mechanisms for storing and retrieving data items is a DBMS if it supports the following items:  Persistence  Programmable structure  Arbitrary size  Access control  Property-based querying  Integrity constraints  Administration  Sharing  Locking  Transactions

Chair of Software Engineering ATOT - Lecture 13, 14 May Object-relational interoperability  Operations: relational algebra: selection, projection, join  Queries: standardized language (SQL)  Usually “normalized”: every field is a simple value; it cannot be a reference “The Carterhouse of Parma”“The Red and the Black”Title“Madame Bovary”“Eugėnie Grandet” date pages author “Stendahl” “Flaubert” “Balzac” Relation books: field tuple (= row) field name (= attribute) column

Chair of Software Engineering ATOT - Lecture 13, 14 May Operations  Selection: date > 1833  Projection  Join “The Carterhouse of Parma”Title“Madame Bovary” date pages author “Stendahl” “Flaubert”

Chair of Software Engineering ATOT - Lecture 13, 14 May Operations  Selection  Projection: on author  Join author “Stendahl” “Flaubert” “Balzac”

Chair of Software Engineering ATOT - Lecture 13, 14 May Operations  Selection  Projection  Join: books authors “The Carterhouse of Parma”“The Red and the Black”Title“Madame Bovary”“Eugėnie Grandet” date pages author “Stendahl” “Flaubert” “Balzac” real name “Henri Beyle” “Gustave Flaubert” “Honorė de Balzac” birth death name “Stendahl” “Flaubert” “Balzac” real name “Henri Beyle” “Gustave Flaubert” “Honorė de Balzac” birth death Relation authors:

Chair of Software Engineering ATOT - Lecture 13, 14 May Using relational databases with O-O software  Comparison of terms:  Class library to provide operations  Usage:  Usage of existing data in relational databases  Simple object structure  Impedance mismatch! Relational relation tuple field name O-O class object attribute

Chair of Software Engineering ATOT - Lecture 13, 14 May Object-oriented databases  Remove impedance mismatch  Overcome conceptual limitations of relational databases:  Data structure must be regular and simple  Small group of predefined types  Normal forms: no references to other “objects”  Attempt to offer more advanced database facilities

Chair of Software Engineering ATOT - Lecture 13, 14 May Requirements for OODBs  Minimal requirements:  Database functionality (listed on slide 27)  Encapsulation  Object identity  References  Additional requirements:  Inheritance  Typing  Dynamic binding  Object versioning  Schema evolution  Long transactions  Locking  Object-oriented queries

Chair of Software Engineering ATOT - Lecture 13, 14 May OODBs examples  Gemstone  Itasca  Matisse  Objectivity  ObjectStore  Ontos  O2  Poet  Matisse  Versant  at ETHZ: OMS Pro

Chair of Software Engineering ATOT - Lecture 13, 14 May Agenda for today  Persistence from programming languages  Advanced topics:  Beyond persistence closure  Schema evolution  From persistence to databases  Commercials

Chair of Software Engineering ATOT - Lecture 13, 14 May Semester- und Diplomarbeiten  Reflection libraries  theoretical part: compare existing reflection APIs  practical part: develop a powerful reflection library for Eiffel  Comparison of serialization mechanisms  discuss and compare existing serialization mechanisms  describe strengths and weaknesses of.NET and Java serialization concepts  implement examples to demonstrate differences/similarities More info:

Chair of Software Engineering ATOT - Lecture 13, 14 May Semester- und Diplomarbeiten  NOOCLEUS:  Scientific computation hasn’t benefited much from object technology  Goal: produce a full O-O library for scientific computation  Object-oriented numerical components  Requires familiarity with both O-O methods and numerical computation  Web-site for NOOCLEUS  Information display, upload, download of components etc.  More info:

Chair of Software Engineering ATOT - Lecture 13, 14 May End of lecture 13