Introduction: OO principles. Introduction: OO principles. 3 Object Oriented Database Systems. 3.1 Introduction: Why OO Databases

Similar documents
Chapter 11 Object and Object- Relational Databases

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Chapter 12 Object and Object Relational Databases

Object Database Standards, Languages, and Design

Copyright 2007 Ramez Elmasri and Shamkant B. Navathe. Slide 21 1

Chapter 21 9/4/2012. Object Database Standards, Languages, and Design. Chapter 21Outline. Chapter Objectives. ODMG Objects and Literals

3. Object-Oriented Databases

Introduction to Databases Object and Object-Relational Databases

ITCS Jing Yang 2010 Fall. Class 16: Object and Object- Relational Databases (ch.11) References

W5.L2. Week 5, Lecture 2

Concepts for Object-Oriented Databases

Part 3: Object-Oriented Database Management Systems

Course Content. Object-Oriented Databases. Objectives of Lecture 6. CMPUT 391: Object Oriented Databases. Dr. Osmar R. Zaïane. University of Alberta 4

Ch. 21: Object Oriented Databases

Advanced Database Applications. Object Oriented Database Management Chapter 13 10/29/2016. Object DBMSs

COURSE 11. Object-Oriented Databases Object Relational Databases

Chapter 13. Object-Oriented Databases (from E&N and my editing)

Object Query Standards by Andrew E. Wade, Ph.D.

Efficient Object-Relational Mapping for JAVA and J2EE Applications or the impact of J2EE on RDB. Marc Stampfli Oracle Software (Switzerland) Ltd.

Introduction to Programming Using Java (98-388)

ODMG 2.0: A Standard for Object Storage

ObjectStore and Objectivity/DB. Application Development Model of Persistence Advanced Features

Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub

Chapter 6 Object Persistence, Relationships and Queries

Constructs in Oracle

Several major software companies including IBM, Informix, Microsoft, Oracle, and Sybase have all released object-relational versions of their

Database Management System. Fundamental Database Concepts

Outline. CUGS Core - Databases. Requirements. Work method. Databanks/Databases. Databank

OBJECT ORIENTED SIMULATION LANGUAGE. OOSimL Reference Manual - Part 1

CIS 330: Applied Database Systems. ER to Relational Relational Algebra

Object Oriented Paradigm

Author's Prepublication Version

DATABASE TECHNOLOGY - 1DL124

Object-Oriented Languages and Object-Oriented Design. Ghezzi&Jazayeri: OO Languages 1

Appendix A - Glossary(of OO software term s)

Chapter 1: Introduction

Topic 3 Object Relational Database

DATABASE MANAGEMENT SYSTEMS. UNIT I Introduction to Database Systems

2.1. Concepts for Object Databases

Chapter 13 Object Oriented Programming. Copyright 2006 The McGraw-Hill Companies, Inc.

Object-Oriented Database Languages. Object Description Language Object Query Language

Chapter 1: Introduction

CGS 2405 Advanced Programming with C++ Course Justification

DISCUSSION 5min 2/24/2009. DTD to relational schema. Inlining. Basic inlining

Introduction. Course Overview Evolution and History of Database Management Systems Requirements of Object-Oriented Database Management Systems

Haskell 98 in short! CPSC 449 Principles of Programming Languages

Database Technology Introduction. Heiko Paulheim

What are the characteristics of Object Oriented programming language?

CompuScholar, Inc. Alignment to Nevada "Computer Science" Course Standards

C++ (Non for C Programmer) (BT307) 40 Hours

ODBMS: PROTOTYPES & PRODUCTS. The ODBMS Manifesto [M.Atkinson & al 89]

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

High Level Database Models

The Relational Model (ii)

Introduction to Visual Basic and Visual C++ Introduction to Java. JDK Editions. Overview. Lesson 13. Overview

Introduction to Amos II

Information Management (IM)

Relational Algebra 1

CSCI-GA Scripting Languages

Short Notes of CS201

CS201 - Introduction to Programming Glossary By

The Relational Model. Chapter 3

CHAPTER 2 LITERATURE REVIEW

Database Application Architectures

STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING

Cardinality constraints,n:m notation

Systems Analysis and Design in a Changing World, Fourth Edition. Chapter 12: Designing Databases

The Object Model Overview. Contents. Section Title

Agent and Object Technology Lab Dipartimento di Ingegneria dell Informazione Università degli Studi di Parma. Distributed and Agent Systems

The Relational Model. Chapter 3. Database Management Systems, R. Ramakrishnan and J. Gehrke 1

Topics in Object-Oriented Design Patterns

COSC 304 Introduction to Database Systems SQL DDL. Dr. Ramon Lawrence University of British Columbia Okanagan

Part III. Data Modelling. Marc H. Scholl (DBIS, Uni KN) Information Management Winter 2007/08 1

COP 3330 Final Exam Review

LECTURE 16. Functional Programming

User-Defined Algebraic Data Types

CS 4604: Introduction to Database Management Systems. B. Aditya Prakash Lecture #5: Entity/Relational Models---Part 1

What s a database system? Review of Basic Database Concepts. Entity-relationship (E/R) diagram. Two important questions. Physical data independence

COP4020 Programming Languages. Functional Programming Prof. Robert van Engelen

CPS510 Database System Design Primitive SYSTEM STRUCTURE

Relational Databases

foreword to the first edition preface xxi acknowledgments xxiii about this book xxv about the cover illustration

CS352 Lecture - Introduction to SQL

Basant Group of Institution

Programming Languages Third Edition. Chapter 7 Basic Semantics

Mahathma Gandhi University

DATABASTEKNIK - 1DL116

Chapter 11. Categories of languages that support OOP: 1. OOP support is added to an existing language

Relational model continued. Understanding how to use the relational model. Summary of board example: with Copies as weak entity

Concepts of Programming Languages

Relational Model History. COSC 304 Introduction to Database Systems. Relational Model and Algebra. Relational Model Definitions.

Object Oriented Database

Chapter 9: Object-Based Databases

3. Relational Data Model 3.5 The Tuple Relational Calculus

CA Compiler Construction

CSC312 Principles of Programming Languages : Functional Programming Language. Copyright 2006 The McGraw-Hill Companies, Inc.

COMP Instructor: Dimitris Papadias WWW page:

Design issues for objectoriented. languages. Objects-only "pure" language vs mixed. Are subclasses subtypes of the superclass?

C++ Important Questions with Answers

The Relational Algebra

Transcription:

Introduction: OO principles 3 Object Oriented Database Systems 3.1 Introduction 3.2 The ODMG data model 3.3 OQL in a nutshell 3.4 Persistence Architectures 3.5 The Object Protocol Model OO DB model: see Kemper / Eickler; Cattell et al: The Object Data Standard: ODMG 3.0, Acedemic Press, 2000 OPM : papers 1,2 Abstraction in OO Languages and DB hide representation, encapsulation use interface operations class Angel { private double angel; // radians public double getdegree() { return java.lang.math.pi * angel /180; public double getrad(){return angel; public void set(double val){ public void setdegree(double val) { Operation interface not forced by most PL or OODB Database terminology: "behavior" of entities if they define operations HS / biodbs04-3-oodb 4 Data models: the spectrum Databases More structure Rigid data models: relational, object-oriented Database conformant to schema Semantics of query q: subset of database No texts, images,... (oríginally) We are here today Semi structured DB / XML Schema more flexible if any Many schema items Text plays a big role Semantics of queries: substructure of DB Information Retrieval Data model: objects are sequences of terms No modeling restrictions (natural language!?) Semantics of query q: DB entries ordered by similarity to q (Ranking) Natural Language VERY difficult to process automatically not really an option Less structure HS / biodbs04-3-oodb 2 Introduction: OO principles Inheritance Type extension / Specialization / Generalization class publication { private String title; private String[] authors; public print(); class book extends publication { private String isbn; private int printing;... public print(){...... type polymorphism and dynamic binding (set_of publication) myset;... not Java! for each d in myset { d.print();... HS / biodbs04-3-oodb 5 3.1 Introduction: Why OO Databases Data modeling: What is appropriate for bio data? No clear answer flexibility, ease of use, few restrictions. Object orientation: much more flexibility than relational systems The essence of Object orientation data abstraction inheritance OO: a programming language paradigm adapted for databases HS / biodbs04-3-oodb 3 Motivation for Objects in databases What is missing in the Relational Model? Type constructors Tuple types Compound structures, recursive structures class Project { Set_Of Sequence sequences; Project project_parent;... Object Identity - Identification of "objects" in RDB by unique value - May change over time? - Frequently artificial keys as a substitute HS / biodbs04-3-oodb 6

Motivation for Objects Data abstraction Encapsulation of state Hiding of representation "Behaviour" Type extensions and inheritance Part of the EER Model Emulated by relations Type versus extent? 3.2 The ODMG Data Model Environment of the OO Database Model (*) C++ Java application DBMS Objectmodel Smalltalk application application Compatibility required: oodb Model and oo language models Defined bindings: C++, Java, Smalltalk, C# HS / biodbs04-3-oodb 7 drawing by FJ Kemper HS / biodbs04-3-oodb 10 Object oriented Programming Languages have all the desired features "Impedance mismatch" View of data and operations on data in DBS and in PL differs heavily Missing: persistence, concurrency, indexing fault tolerance, query language HS / biodbs04-3-oodb 8 ODMG Type System Types Atomic literal types Primitive types integer, float,.. character, char strings, boolean, enum Literal Collection literal types Types set, bag list, array of any (single) type dictionary structures (record, C / C# struct) struct conditions { float humitiy; float pressure ; float temperature;; set <enum strategy_type (shotgun, primer, del_clone, genomic, transposon)> strategy_set; HS / biodbs04-3-oodb 11 Object oriented Programming Environment Persistent PLang as a substitute for DBS? Data model tightly bound to OO paradigm but data live independent of any programming model Data model should be suited for all kinds of programming models Simplistic RDM a good compromise? No common OO data model Eiffel, Java, C++, C#, Smalltalk, Standardization needed! Object Data Management Group (ODMG) * data model (1993) Competing approach: extension of the RDM by OO concepts HS / biodbs04-3-oodb 9 * Different from Object Management Group (OMG) for Corba standardization ODMG Type System Class Types Define "state and behaviour " of objects of this type Behaviour: operations (methods, functions) State : attributes and relationships Class types can be instantiated: new... class Experiment { attribute struct {float humitiy; float pressure ; float temperature; cond; attribute time t ; attribute People experimenter ; // an object attribute set <enum ExType (ALPHA, BETA, PI)> experimenttype HS / biodbs04-3-oodb 12

ODMG Data Model Relationships Associate one object of class C1 to one or more of class C2 Only binary relationships, recursive relationships (C1 == C2) allowed relationship People experimenter inverse Experiment::makes; Relationships preserve integrity ("foreign keys") in contrast to attributes: attribute People experimenter; 1:1, 1:N, M:N relationships implementation of relationships encapsulated by public operations for drop and form members HS / biodbs04-3-oodb 13 ODMG Data Model Extents Class type may be associated with an extent Extent of class type T: set of all objects of T class People (extent ThePeople class type and its extent key name, first_name must be named differently ) {... Keys class type may have a key of one or more of its attributes values must be unique HS / biodbs04-3-oodb 16 Relationships M:N relationships class People{... relationship set <Experiment> makesexperiments inverse Experiment::experimenter; class Experiment{... relationship set <People> experimenter inverse People::makesExperiments; - collection types different from set can be used: bag, list, array HS / biodbs04-3-oodb 14 ODMG Data Model Inheritance Single inheritance supported by classes ("extends") Inheritance of state and behaviour class People {... void writereport(in: RType typofrep )raises (nosuchtype);) ; class Scientist extends People {... attribute set <subject> fields;... ; define enum subject (chem,bio,phys,bioinf) HS / biodbs04-3-oodb 17 ODMG Data Model: Operations Behaviour: Operations Method specifications (syntax ) with in, out, inout parameters Syntax identical to Corba interface definition exceptions Implementation in binding language class Experiment{... void writereport(in: RType typofrep )raises (nosuchtype); // specification as comment. // implementation: binding language... ; HS / biodbs04-3-oodb 15 ODMG Data Model Inheritance and extents Subset relationship of extents to be maintained by system class People (extent ThePeople) {... void writereport(in: RType typofrep )raises (nosuchtype);); ; class Scientist extends People (extent Scientists {... attribute set <subject> fields;... ; For each valid DB state Scientists ThePeople HS / biodbs04-3-oodb 18

ODMG Data Model Multiple interitance by interfaces (sic!) Employees is-a Tutors Employees implements interface inherits Students No way to express by class inheritance EmpIF Tutors Students HS / biodbs04-3-oodb 19 OQL path expressions Navigation through object graph using predefined relations isofferedby worksin Course Prof Department "Find name of department which offers the course "Topology" Select x.isofferedby.worksin.name from course x where x.name = "Topology" ) Only allowed for n:1 / 1: 1 relationships Example: exactly one prof for course, exactly one dep for prof HS / biodbs04-3-oodb 22 3.3 ODMG / Object Query Language (OQL) Language characteristics Query language with SQL flavour Declarative access to objects from application define bioscientists as select x from Scientists x where bio in x.fields ) Defines an extent Extent is queried No updates: use methods which manipulate state Means to traverse the object graph OQL may invoke methods programmed in the language of the binding, e.g. Java, C++ HS / biodbs04-3-oodb 20 OQL path expressions Navigation through relationship sets hasprof teaches Department Professor Course "Find professors from all departments with their offered courses, provided the course is an introduction and more than 1 is offered" select * from departments x, x.hasprofs as y, Explicit iterator variables y,z y.offers as z where z.name like "%ntroduction%" ) Result type: bag <struct (x: Department, y: Prof, z: Course)> HS / biodbs04-3-oodb 23 OQL typed result sets Simple queries and result sets ThePeople // collection of all people objects select x // has type bag <Employee> from Scientists x where bio in x.fields select distinct x.name // has type set <string> from Scientists x where set (math,bio) in x.fields select distinct struct (a: x.name, b:x.fields) from Scientists x // Type: set<struct {a:string, // b:set<subject>> HS / biodbs04-3-oodb 21 OQL methods in queries and subselects "Find employees x with higher salary than 10K and for each x those who are paid higher" select struct (n: x.name, hipaid : (select y from employees where y.sal.monthlypayment > x.sal. monthlypayment )) from employees x, where x.sal.monthlypayment > 10000 ) Result type:bag <struct (x: string, y: bag<employee>)> x.y and x -> y are equivalent notations HS / biodbs04-3-oodb 24

OQL collection expressions Quantifiers for all x in e1:e2 exists x in e1: e2 are expression, if e1 denotes a collection and and e2 is an expression of type boolean select x.name from Experiments x where for all y in x.experimenter: math in x.fields Aggregation max, min, sum,avg may be applied to collection e of numeric type count (select x.experimenters from Experiments x ) count can be applied to any collection type object HS / biodbs04-3-oodb 25 OQL Polymorphism Polymorphic type system of ODL Late binding to carry out operations on polymorphic collections Single dispatch select struct (n: e.name, e: p.sal) // assumed: operation sal from People e sal operation is dispatched according to dynamic type of an People object. People Assistant Scientist HS / biodbs04-3-oodb 28 OQL Partitioning Partitioning by means of group by Groups may be referred to by partition variables find average salary of all departments with more than 10 emps OQL: select deptname, avg(select p.sal.monthlypayment from partition p) from employees e group by deptname: e.dep.name Emp Dep having count (partition) > 10 Type of result of group by operator: type( group by f 1 :e 1, f k :e k ) = set <struct (f 1 :t 1, f k :t k, partition: bag<b>)> and type( e i ) = t i, type ( partition) = B, where B is type of from-clause HS / biodbs04-3-oodb 26 OQL Type specifiers as in Java and other oo languages select ( (Scientist) e).subject from People e where e.sal.monthlypayment > 4000 // if only scientists earn more than 4000 Constructing objects People(name: "Abel", id: 23, sal: Salary(1000,0,0,0,0), fields: set(bio,math), makesexperiments: set()) HS / biodbs04-3-oodb 29 OQL : more language features Set expressions union, except, intersect employees except profs Indexed expressions: e of type list(t) or array(t), e' of type integer, then e[e'] is of type t and x[i] denotes the i+1 th element of the indexed collection x Joins? Necessary at all? Yes, if not all relationships anticipated in the schema select p from Prof p, Student s where p.name = s.name HS / biodbs04-3-oodb 27 OQL language design OQL is a purely functional language SQL expressions Ad hoc - in contrast to relational algebra OQL expressions: Typed Freely composed by operators - as long as type system is respected => Orthogonality of the language HS / biodbs04-3-oodb 30

OO database systems Systems Poet, Ontos, O2, ObjectStore,... Do not implement all features of ODMG standard decreasing importance (?) Significance Useful for modeling complex domains Object relational systems more important Object relational Mapping architectures use Standard RDBS HS / biodbs04-3-oodb 31 Persistence Framework Features Implicit persistence: - framework automatically makes business objects persistent - no action taken by application program Examples: Enterprise Java Beans, Java Data Objects (container managed) Explicit persistence - application program indicates when to save Most common in Persistence frameworks DB access generated.. dynamically: flexible at compile time: simpler, better performance during system start up (example: Hibernate framework) HS / biodbs04-3-oodb 34 3.4 Persistent objects Design principles Keep language clean from DB access code "persistence manager" between client code and DB DB specific code generated for use by the persistent mgr Client space DB access code e.g. Object- -Relational mapping, Persistence layer Database layer any type allowed: -Relational -Object oriented -Object relational HS / biodbs04-3-oodb 32 3.5 OPM Object Protocol Model data model for genomic data (1993) subset of oo data models no inheritance, set operations, explicit relationships,... "protocol classes" intended for modeling the flow of data / control in experiments useful for modeling steps and their interrelationships of experiments Implemented on top of relational (or oo) DBS HS / biodbs04-3-oodb 35 Persistence Framework Mapping between DB data and objects defined in a Meta Data Repository (XML document, database, ) Basic functionality: create, read, update, write, transaction support Enhanced: fault tolerance, mapping generation, caching etc. Protocols Experiments process chain / graph of activities each having input attributes of the activity (what, when,... dependent on activity output relational / object oriented modeling? OPM designed to model data and data flow, not operations basic innovation: interconnection of activites Figure S. Amber HS / biodbs04-3-oodb 33 HS / biodbs04-3-oodb 36

Example cf. Chen, Markowitz: the Object-Protocol Model, TR LBL-32738, Lawrence Berkeley lab HS / biodbs04-3-oodb 37 Summary Object models much more flexible than relational OO programming languages have (different) underlying models OO DB model standardized (Definition ODL, Query OQL) Mapping to language model essential Significance decreasing with object-relational mapping frameworks... and with XML? HS / biodbs04-3-oodb 40 Example: Definition of a Protocal HS / biodbs04-3-oodb 38 Example (cont) HS / biodbs04-3-oodb 39