Top Banner
06/06/22 DBIS: Beyond RDBMS 1 Database and Information Systems Beyond RDBMS Lectures based on material from Phil Trinder (HW) , Connelly & Begg textbook Monica Farrow G30 email : [email protected]
46
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 1

Database and Information Systems

Beyond RDBMSLectures based on material from

Phil Trinder (HW) , Connelly & Begg textbook

Monica Farrow G30 email : [email protected]

Page 2: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 2

Topics

Impedance mismatch Persistence OR Mapping Frameworks Limitations of RDBMS OODBMS ORDBMS

Page 3: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 3

Basic Object Relational Mapping

Programming code and SQLe.g. ODBC/JDBC

Page 4: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 4

Introduction

The situation is that :

Relational databases are highly commercially successful (Oracle, DB2, SQL Server, etc)

Most databases are relational

SQL is not computationally complete

Most programming languages are now object-oriented

Therefore many applications use a RDBMS as their data store while using an object-oriented programming language for development

This requires some form of SQL within the programming language

Page 5: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 5

Flattening

For anything other than extremely simple systems, it is likely that good OO program design requires :

Converting the ResultSet which is returned by the query into an object

Using the functionality provided by the object’s class to process the results

Objects must be mapped to tables in the database (‘flattened’) and vice versa

It is estimated that as much as 30% of programming effort and code space is expended on this type of conversion

Page 6: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 6

Impedance mismatch

This is the term used for the complexity introduced by constructing programs using these two different systems, relational databases and object-oriented programming http://service-architecture.com/object-oriente

d-databases/articles/impedance_mismatch.html

http://www.agiledata.org/essays/impedanceMismatch.html

Page 7: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 7

Impedance mismatch

Constructing programs this way is arduous and error-prone

Relational model uses set operations, Java has OO model with iteration, one record at a time

Data structures need to be constructed from the relations before manipulations, and flattened before storage

Relational Domains may differ from class types The relational model does not support inheritance ‘Many to many’ relationships are unlikely to map

directly to classes SQL and Java cannot be simply combined SQL queries cannot be always be statically checked

and may produce errors

Page 8: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 8

Persistence

One of the most critical tasks that applications have to perform is to save and restore data

Persistence is the storage of data from an application’s working memory so that it can be restored when the application is run again

Page 9: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 9

Object-Relational Mapping Frameworks

Much effort has been put in recently to making object-relational mapping more convenient

The framework handles the mapping of the objects to relational database tables where they are actually stored

Selected objects are initially marked as being persistent

thereafter, changes in those objects are transparently changed in the database

the programmer does not have to write code specifically to update the database

Examples Hibernate, Castor, OJB, JDO….

Page 10: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 10

OR Mapping Frameworks contd

Using a framework provides:

Transparent persistence

Object classes do not contain db details The programmer can work only with objects

no SQL statements in the code Could be used with different database Easier to code

Mapping of objects to database tables is defined, usually in XML descriptor files

An extra ‘persistance layer’ is automatically inserted between the compilation and execution

Page 11: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 11

OR Mapping Frameworks

Page 12: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 12

RDBMS advantages

There are advantages in using a Relational Database Management System The relational database has a strong

theoretical foundation which supported the development of SQL

Simple Suitable for Online Transaction Processing,

which is used by many business applications Supports data independence

Page 13: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 13

Advanced Database Applications

Many advanced database applications are unsuitable for the relational model

Computer-Aided Design/Manufacturing (CAD/CAM) Computer-Aided Software Engineering (CASE) Network Management Systems Office Information Systems (OIS) and Multimedia

Systems Digital Publishing Geographic Information Systems (GIS) Interactive and Dynamic Web sites Other applications with complex and interrelated

objects and procedural data.

© Pearson Education Limited 1995, 2005

Page 14: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 14

RDBMS Limitations

Impedance Mismatch (discussed)

Entity may be fragmented into many relations, needing joins (which is costly) during query processing

Semantic overloading Only one construct (the relation) for modelling relations

AND relationships

Poor at navigational access from record to record Good for access by specifying criteria

Not enough support for integrity and business constraints

Referential integrity not always supported Business constraints may need specifying within DBMS or

application

Page 15: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 15

RDBMS Limitations continued

Homogeneous data structure All rows must contain the same columns All columns must come from same domain Values must be atomic Now some RDBMS permit Binary Large Objects

(BLOBs), suitable for multimedia or other unstructured object

Limited operations SQL does not permit new business-specific operations

E.g. intersection of lines, mathematical formulae

SQL cannot perform recursive queries Not designed for long transactions – 2-phase locking

is unsuitable Difficult to alter the schema

Page 16: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 16

Example of complex data structure : Bill of Material

© Pearson Education Limited 1995, 2005

Cake

Icing Mixture

SugarWater Eggs Fruit

ID Name Cost

P1 Water 0

P2 Fruit 90

P3 Eggs 12

P4 Sugar 44

BasePart

ID Name

P10 Icing

P11 Mixture

CompositePart

IDCP IDBP

P10 P1

P10 P4

P11 P4

P11 P2

P12 P3

ConsistsOfComplex data structures can be more easily represented in OOPL(graph)

Page 17: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 17

Persistence through Object Serialization

Simple persistence method which provides a program the ability to read or write a whole object to and from a stream of bytes

Allows Java objects to be encoded into a byte stream suitable for streaming to a file on disk or over a network. The bytes can be rebuilt into a live object in the future.

The class must implement the Serializable interface (java.io.Serializable)

Simple, but does not support DBMS features such as multi-users, partial retrieval, transactions, recovery etc

Page 18: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 18

Persistence through Object Serialization

Page 19: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 19

Using Databases

There are essentially three approaches which have been developed for the management of object storage in databases:

the Object-Oriented Database Management System (OODBMS)

Extend OO programming language with persistence

the Object-Relational Database Management System (ORDBMS)

Extend relational system with object features Object Relational Mapping

Already discussed

Page 20: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 20

Object Oriented Database

Management SystemsOODBMShttp://service-architecture.com/object-oriented-databases/articles/index.html

http://www.odbms.org/downloads.html

Page 21: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 21

Object Data Model

Page 22: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 22

OODBMS Manifesto

To establish agreement on what an OODBMS is, (Atkinson et al. 1990) propose the following 13 rules:

Object characteristics Complex objects must be supported. Object identity must be supported.. Encapsulation must be supported.. Types and classes must be supported. Types and classes must be able to inherit from their

ancestors. Dynamic binding must be supported The DML must be computationally complete. The set of data types must be extensible.

Page 23: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 23

OODBMS Manifesto contd

DBMS characteristics Data persistence must be provided The DBMS must be capable of managing

very large databases The DBMS must accept concurrent users. The DBMS must be capable of recovery from

hardware and software failures. The DBMS must provide a simple way of

querying data.

Page 24: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 24

The ODMG Proposed Standard

One of the crucial factors in the commercial success of RDBMSs is the relative standardisation of the data model

The Object Data Management Group (ODMG) was formed by a group of industry representatives to define a proposed standard for the object data model.

It includes an Object Definition Language (ODL) and Object Query Language (OQL)

It is still far from being as widely recognised as the relational database standards.

Page 25: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 25

Object Identity

In an OODb, an object is identified by an object identifier (oid), and objects are related by storing the oid of one object in another.

The crucial distinction between oids and addresses is that an oid is not related to the object’s physical location, whereas an address is.

The object’s physical location changes between main memory and the database, managed by the DBMS

The object identifier is not visible to the user or database programmer

Page 26: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 26

Using an OODBMS

The programmer defines the persistent data

Subsequently, they do not have to know about Format of data storage Transfer of persistant data between main

memory and database This happens transparently and is managed

by the OODBMS

The programmer can start and commit transactions

Page 27: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 27

Advantages of OODBMSs

Enriched Modelling Capabilities. Extensibility. Removal of Impedance Mismatch. More Expressive Query Language. Support for Schema Evolution. Support for Long Duration Transactions. Applicability to Advanced Database

Applications. Improved Performance.

Page 28: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 28

Disadvantages of OODBMSs

Lack of Universal Data Model. Lack of Experience. Lack of Standards. Query Optimization compromises

Encapsulation. Object Level Locking may impact

Performance. Complexity. Lack of Support for Views. Lack of Support for Security.

© Pearson Education Limited 1995, 2005

Page 29: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 29

When to use

In general, RDBMSs are probably more suitable for databases with a variety of query and user interface requirements i.e. most mainstream business applications

OODBMSs are appropriate for applications with complex, irregular data, where data access will follow predictable patterns e.g CAD/CAM systems, manufacturing

databases

Page 30: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 30

OODBMS Users

The Chicago Stock Exchange - managing stock trades

CERN in Switzerland - large scientific data sets

Radio Computing Services – automating radio stations (library, newsroom, etc)

Adidas – content for web site and CD-ROM catalogue

Federal Aviation Authority – passenger and baggage traffic simulation

Electricite de France – managing overhead power lines

Page 31: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 31

Object Relational Database

Management SystemsORDBMS

Page 32: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 32

Market Share

RDBMSs currently dominant database technology with estimated sales $6 - $10 billion per year ($25 billion with tools sales included).

OODBMS market still small, but still finds new applications areas.

Some analysts expect OODBMS market to grow at a faster rate than total database market, but unlikely to overtake relational systems. © Pearson Education Limited 1995, 2005

Page 33: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 33

ORDBMSs

Vendors of RDBMSs conscious of threat and promise of OODBMS.

Agree that RDBMSs not currently suited to advanced database applications, and added functionality is required.

Reject claim that extended RDBMSs will not provide sufficient functionality or will be too slow to cope adequately with new complexity.

Can remedy shortcomings of relational model by extending model with OO features. © Pearson Education Limited 1995, 2005

Page 34: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 34

ORDBMSs - Features

OO features being added include: user-extensible types encapsulation inheritance polymorphism dynamic binding of methods complex objects including non-1NF objects object identity

© Pearson Education Limited 1995, 2005

Page 35: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 35

ORDBMSs - Features

However, there is no single extended relational model

All models: share basic relational tables and query

language all have some concept of ‘object’ some can store methods (or procedures or

triggers)

Some analysts predict ORDBMS will have 50% larger share of market than RDBMS.

© Pearson Education Limited 1995, 2005

Page 36: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 36

The Object Relational Model

Page 37: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 37

SQL:2003 - New OO Features

Type constructors for row types and reference types

User-defined types (distinct types and structured types) that can participate in supertype/subtype relationships

User-defined procedures, functions, methods, and operators

Type constructors for collection types (arrays, sets, lists, and multisets)

Support for large objects – BLOBs and CLOBs

Recursion© Pearson Education Limited 1995, 2005

Page 38: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 38

ORDB Example - Oracle

User defined type CREATE TYPE Name AS OBJECT (

first_name CHAR (15),last_name CHAR (15),middle_initial CHAR (1);MEMBER PROCEDURE initialize,;

Code to define operations – here simply a class constructorCREATE TYPE BODY Name AS

MEMBER PROCEDURE initialize ISBEGIN

first_name := NULL;last_name := NULL;middle_initial := NULL;

END initialize;END;

Page 39: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 39

ORDB Example contd - Oracle

Using the new type in a table

CREATE TABLE person(person_ID NUMBER;person_name Name,PRIMARY KEY (person_ID));

Page 40: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 40

Stonebraker’s View

© Pearson Education Limited 1995, 2005

Page 41: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 41

Advantages of ORDBMSs

Resolves many of known weaknesses of RDBMS

Reuse and sharing: reuse comes from ability to extend server to

perform standard functionality centrally; gives rise to increased productivity both for

developer and end-user.

Preserves significant body of knowledge and experience gone into developing relational applications.

© Pearson Education Limited 1995, 2005

Page 42: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 42

Disadvantages of ORDBMSs

Complexity

Increased costs

Proponents of relational approach believe simplicity and purity of relational model are lost

Some believe RDBMS is being extended for what will be a minority of applications

OO purists not attracted by extensions either

SQL now extremely complex. © Pearson Education Limited 1995, 2005

Page 43: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 43

Data modelling comparison ORDBMS/OODBMS

Page 44: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 44

Data sharing comparison ORDBMS/OODBMS

Page 45: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 45

Page 46: Beyond RDBMS - for interest only

04/08/23 DBIS: Beyond RDBMS 46

Summary

Relational databases are widely established An application needs programming capability as

well as just a relational database There is an impedance mismatch between the

objects in an object-oriented program and relations in the database

OR Mapping frameworks handle the mapping from object to relation

Object-oriented databases occupy a niche in the market. The data in the application persists from one run to the next.

Many relational databases now have been extended to support OOP concepts