object-oriented database - social.stoa.usp.br · object query language developed by odmg, object...

Post on 01-May-2019

231 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Object-Oriented DatabaseFelipe BrigalanteHugo Mitsumori

Revisor: Mateus Rocha Mazzari

1

Database● Collection of related data with inner meaning

● Represents real world aspects

● Can be maintained and manipulated using a DBMS

● Can be used by applications to provide data persistence

● Different model types. Ex: relational, document, graph, key-value, object-

oriented, etc

2

Relational Databases● Created in 1970

● Store and access of data via relations (tables)

● Conceptual model and physical storage

● Structured Query Language

● PC’s and Large servers

● The most used for traditional applications

3

Object mapping issues for relational databases● Encapsulation

● Inheritance

● Data types

● Structural

4

The appearance of OODB● Advent of the oriented-object languages

● Necessity to store and share complex objects

● 80s: begin of researches for OODB

○ Development of the first OODB Management Systems

● Lack of standards

● ODMG fundation

● Today: Object-Relational Databases5

General Features● Complex Objects

● Object Identity

● Encapsulation

● Types and Classes

● Hierarchy

● Overriding, overloading, late binding

6

General Features● Complex Objects

○ Simple Objects: Integers, Chars, booleans, byte strings, etc

○ Constructors: List, Bags, Arrays, Sets, Tuples, etc

○ Complex Objects: Simple Objects with “constructors”

○ Operations: Deletion and Update propagations, copy

7

General Features● Object Identity

○ Identity vs Equality

○ Object Sharing

○ Object Update

○ Operations: Object Assignment, Copy, Equivalence Tests

8

General Features● Encapsulation

○ Data and operation

○ Indirect access to data and restriction

○ Hidden data information and operations implementation

○ Logical data independence

9

General Features● Types and Classes

○ Type: summarizes common features of a set of objects

■ Interface + Implementation

■ Only the Interface is visible

○ Class

■ Concrete structure

■ Two aspects: Object Factory and Object Warehouse

■ Manipulation of Objects

10

General Features● Hierarchies (Inheritance)

○ Substitution

○ Inclusion

○ Constraint

○ Specialization

11

General Features● Overriding, overloading and late binding

○ Overloading: different signatures for the same method

○ Overriding: substitute the implementation of a method

○ Late binding: bind operations names with the program at run-time

12

Other Mandatory Features● Computational Completeness● Extensibility● Persistence● Secondary storage management● Concurrency● Recovery● Ad Hoc Query facility

13

Standards● Object Data Management Group (ODMG), put a set of specifications with

respect to:○ Data Schema○ Programming Language Bindings (Smalltalk, Java and C++)○ Data Manipulation○ Query Languages

● Between 1993 and 2001, the ODMG published five revisions to its specification. The last revision was ODMG version 3.0, after which the group disbanded.

14

Object Definition Language1. Defined by ODMG standards

2. Defines the interface to object types

3. Creates an abstraction layer, making data language and database

implementation independent

15

Object Definition Language - Banking Example

Cardinality constraint: each loan belongs to a single branch16

Object Definition Language - Exampleinterface Customer {

attribute integer ss#;attribute string name;attribute Struct Addr {string street, string city, int zip} address; relationship Set<Loans> borrowed inverse Loans::borrower;relationship Set<Branch> has-account-at inverse Branch:patrons;key(ss#)

}

17

Object Definition Language - Exampleinterface Loan {

attribute real amount;attribute int loanid;attribute Enum loanType {house, car, general} type; relationship Branch belongs-to inverse Branch::loans-granted; relationship Set<Customer> borrower inverse Customer::borrowed;key(loanid)

}

18

Object Definition Language - Exampleinterface Branch {

attribute integer branchid;attribute Struct Customer::Addr location;relationship Se<Loans>t loans-granted inverse Loans::belongs-to; relationship Set patrons inverse Customer::has-account-at;key(branchid);

}

19

ODL Type System● Basic types: int, real/ float, string, enumerated types, and classes

● Type constructors: Struct for structures and four collection types: Set, Bag, List, and Array

20

ODL Subclasses● Example: Faculty and Staff are subclasses of Employee. Faculty have

academic year (9 month salaries) but staff has a full-year (12 month salary)

● Follow name of subclass by colon and its superclass.○ interface Faculty:Employee { attribute real academic-year-salary; }

● Objects of the Faculty class acquire all the attributes and relationships of the Employee class.

21

Object Query Language● Developed by ODMG, Object Query Language allows SQL-like queries to

be performed on a OODB● Like SQL, it is a declarative language. Based loosely on SQL, OQL includes

additional language constructs which allow for object oriented design such as operation invocation and inheritance.

● OQL only refers to SELECT statements. SQL includes both DDL and DML statements.

22

Object Query Language - Example● List all books written by someone whose name starts with ‘Camus’

○ SQL:

■ SELECT Book JOIN Artist ON Book.written_by = Artist.id WHERE Artist.name LIKE ’Camus%’

○ OQL:■ SELECT Book WHERE Book.writer.name LIKE ’Camus%’

● Audio, Video and Book are subclasses of Item. How to list items not being produced by a French company○ SELECT Item WHERE item.producer.country != ’France’

23

Native Queries● In 2005 was proposed to drop all standardization efforts to introduce

additional object-oriented query APIs but rather use the OO programming language itself

● Example using db4o with Java native query:○ // Find all the Brians

ObjectSet brians = db.get(new Person("Brian", null, 0));while (brians.hasNext())

System.out.println(brians.next());

24

Advantages and disadvantages

25

Advantage Disadvantage

● Complex objects & relations● Class hierarchy● No impedance mismatch● One data model● High performance on certain tasks● Less programming effort because

of inheritance, re-use and extensibility of code

● Schema change (creating, updating) is non trivial, it involves a system wide recompile.

● Language dependence: tied to OO languages (or specific languages when using native queries)

● Lack of Ad-Hoc query

Bibliographic References● The Object-Oriented Database System Manifesto

● http://wwwbayer.in.tum.de/lehre/WS2001/HSEM-bayer/OODBMS.pdf

● http://www.ics.uci.edu/~dbclass/ics184/class-notes/odl.pdf

● Sistemas de Bancos de Dados (6a edição), Elmasri e Navathe. Pearson, 2010

● Foundations of object relational mapping, Mark Fussell

26

top related