CSC/ECE 517 Summer 2008/wiki3 1 ar: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
Line 28: Line 28:


=== Mismatches ===
=== Mismatches ===
==== Encapsulation ====
==== * Encapsulation ====


== Techniques for merging Relational and OO models ==
== Techniques for merging Relational and OO models ==

Revision as of 16:41, 25 July 2008

WIKI Topic - RDB/OO patterns

It would be good if OO programs could interact with OO databases, but alas, relational databases have a 99% market share. This has led to many attempts to access them from OO languages. Design patterns for doing this have been developed, starting with Crossing Chasms and extending to Rails' ActiveRecord [1][2]. Here, we investigate the various approaches for marrying OO programs to relational databases, comparing them in terms of ease of programming, robustness, and efficiency.

Introduction

This article deals with merging two software development models. Most of data are already stored in relational databases that are modeled around relational models. But all new development is being done in some Object Oriented language. Software design patterns are providing a solution in terms of ORM (Object Oriented Mapping) to merge these two models.

In this article first I will set the stage by giving some background information about the relational model and object oriented models and their differences. After this I will briefly discuss the philosophical approaches to merge them together. By then user should have a good understanding of the problem and techniques to solve it, now it is time to show some design patterns that solve this problem in very elegant way. I will pick two major design patterns that are mostly used by development teams.

Relational Vs Object-Oriented Models

Relational Models

This model deals with data structure and suggests the relational theory to organize it. It was proposed by Edgar Codd in 1969. It is the foundation of every modern database. It defines a logical view of data based on two concepts.

  1. Domain/data type
  2. Relations

The domain simply represents a set of values which is equivalent to data type in programming languages. A relation over the domain D1, D2, …, Dn is simply a subset of the Cartesian product; usual notation is R “include in” D1xD2x…xDn. An element of a Cartesian set is called a tuple. So we could say "A database is a collection of relation valued variables, together with set of integrity constraints that the data must satisfy."

Object-Oriented Models

Orient-Oriented models consist of objects that have both data and behavior. They usually represent the real word better than rational models do. There are lots of general purpose object oriedned languages available to support such type of model. Now days most of development done through this approach.

Differences between Relational Vs Object-Oriented Models

The Object-oriented models are based on the best practices of the latest software engineering principles where as relational models are based on proven mathematical principles. You find more impedance when you actually try to follow one model. In Object Oriented models, objects traverse through their relationships with other objects whereas in relational model you join rows of data. That makes them two totally different approaches. Following is an example of such two cases,

Relational Model example (Customer and Customer Address)

Object Oriented Model example (Customer and Customer Address)

Mismatches

* Encapsulation

Techniques for merging Relational and OO models

Minimize the differences

Compensation

Object/Relational Mapping (ORM) Patterns

Conclusion

Links