Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Mapping to Relational Databases Presented by Ramona Su.

Similar presentations


Presentation on theme: "1 Mapping to Relational Databases Presented by Ramona Su."— Presentation transcript:

1 1 Mapping to Relational Databases Presented by Ramona Su

2 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/)http://www.service-architecture.com/object-relational-mapping/

3 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

4 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)

5 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)

6 6 Loading/Saving Problem Problem with consistency Problem with isolated reads Solutions Unit of Work Possible performance degradation Identity Map Performance boost Lazy Load Performance boost

7 7 Structural Problem Mapping relationships problems Difference in representation Multiple references and links Many-to-many relationship Solutions Identity Field Foreign Key Mapping Association Table Mapping

8 8 Structural Problem Continued Inheritance SQL cannot handle inheritance Solutions Single Table Inheritance Concrete Table Inheritance Class Table Inheritance Tradeoff between duplication of data and speed of access

9 9 Structural Problem Continued

10 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

11 11 Metadata Use metafile for mapping Avoids repetitive code Can build queries in terms of objects Query Object Repository

12 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?

13 13 Questions? Any questions or comments?


Download ppt "1 Mapping to Relational Databases Presented by Ramona Su."

Similar presentations


Ads by Google