mapping to relational databases

13
1 Mapping to Relational Databases Presented by Ramona Su

Upload: evers

Post on 19-Jan-2016

76 views

Category:

Documents


1 download

DESCRIPTION

Mapping to Relational Databases. Presented by Ramona Su. Overview. Role of the database DB plays dominant role in the data source layers for most systems Storing persistent data Maintain internal records Core part of some scientific investigation What is object-relational mapping? - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Mapping to Relational Databases

1

Mapping to Relational Databases

Presented by Ramona Su

Page 2: Mapping to Relational Databases

2

Overview

Role of the database DB plays dominant role in the data source layers for

most systems Storing persistent data Maintain internal records Core part of some scientific investigation

What is object-relational mapping? Object-relational mapping is used to map object-

oriented programming objects to relational databases managed by relational database managers. (http://www.service-architecture.com/object-relational-mapping/)

Page 3: Mapping to Relational Databases

3

Overview

Why is object-relational mapping important? Many systems use a relational DB

SQL has helped make a relational DB successful Better understood & proven technology over OO DB Data already exists in a relational DB Technical or political reasons for using a relational DB

Creating an abstraction Takes advantage of transparent persistence Reduces code Improves performance

Page 4: Mapping to Relational Databases

4

Types of Databases Object Oriented DB

Users can define their own methods of access to data and how it is represented and manipulated

Database objects appear as programming language objects in one or more object programming languages

No problem of O/R Mapping Improves productivity

Relational DB Ted Codd’s paper “A Relational Model for Large Shared Data

Banks” “It provides a means of describing data with its natural structure

only--that is, without superimposing any additional structure for machine representation purposes. Accordingly, it provides a basis for a high level data language which will yield maximal independence between programs on the one hand and machine representation on the other.” (Codd, 1970)

Page 5: Mapping to Relational Databases

5

Architectural Patterns

Important part of design Types of patterns

Gateway (separating access to DB) Row Data Gateway Record Set

Domain Model (incorporates data and behavior) Active Record

Data Mapper (insulate domain objects and DB from each other)

Page 6: Mapping to Relational Databases

6

Loading/Saving Problem

Problem with consistency Problem with isolated reads Solutions

Unit of WorkPossible performance degradation

Identity MapPerformance boost

Lazy LoadPerformance boost

Page 7: Mapping to Relational Databases

7

Structural Problem

Mapping relationships problems Difference in representation Multiple references and links Many-to-many relationship Solutions

Identity FieldForeign Key MappingAssociation Table Mapping

Page 8: Mapping to Relational Databases

8

Structural Problem Continued

Inheritance SQL cannot handle inheritance Solutions

Single Table Inheritance Concrete Table InheritanceClass Table InheritanceTradeoff between duplication of data and

speed of access

Page 9: Mapping to Relational Databases

9

Structural Problem Continued

Page 10: Mapping to Relational Databases

10

Connection Problem

Ensuring connection is opened when it needs to be, or closed when you’re done accessing

Managing connection solutions Pass it as a parameter Garbage collection Tie it to a transaction

Connection can cause concurrency issues

Page 11: Mapping to Relational Databases

11

Metadata

Use metafile for mapping Avoids repetitive code Can build queries in terms of objects

Query Object Repository

Page 12: Mapping to Relational Databases

12

Discussion

It seems like you must do a lot more work with O/R mapping than if you used a OO DB. How can we make use of OO DB more successful?

Page 13: Mapping to Relational Databases

13

Questions?

Any questions or comments?