CSC/ECE 517 Fall 2009/wiki3 12 sn: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
Line 10: Line 10:
To understand mapping we must start with the class whose objects need to be mapped. An attribute of such a class will then be mapped to a single or multiple columns of a relational database table. The simplest form of mapping is the mapping of an attribute to a single column and both the entities being mapped have the same data type. For example, a date attribute is mapped to a date type column [2].   
To understand mapping we must start with the class whose objects need to be mapped. An attribute of such a class will then be mapped to a single or multiple columns of a relational database table. The simplest form of mapping is the mapping of an attribute to a single column and both the entities being mapped have the same data type. For example, a date attribute is mapped to a date type column [2].   


==Patterns in ORM==
There are several patterns or techniques used to implement ORM in different situations. Let us see some of them in detail.
===Concrete Table Inheritance===
In this technique, each class is mapped to its own table such that both the attributes implemented by the class and its inherited attributes are mapped to the table. Following is an example to explain this technique:
[[Image:mappingClassHierarchy.gif|250 px|left]]
[[Image:mappingConcreteToTable.gif|250 px|right]]
[2]


==References==
==References==

Revision as of 05:04, 18 November 2009

Patterns for Mapping Objects to Relational Databases

Introduction

Mapping Objects to Relational Databases is also referred to as Object-relational mapping or ORM. It is a programming technique for converting data between incompatible type systems in relational databases and object-oriented programming languages which creates a virtual object database that can be used from within the programming language [1]. The term "mapping" is used to refer to how objects and their relationships are mapped to the tables and relationships between them in a database [2]. The following figure shows a high-level depiction of ORM [3]:


ORM [3]
ORM [3]

Fundamentals of Mapping

To understand mapping we must start with the class whose objects need to be mapped. An attribute of such a class will then be mapped to a single or multiple columns of a relational database table. The simplest form of mapping is the mapping of an attribute to a single column and both the entities being mapped have the same data type. For example, a date attribute is mapped to a date type column [2].


Patterns in ORM

There are several patterns or techniques used to implement ORM in different situations. Let us see some of them in detail.

Concrete Table Inheritance

In this technique, each class is mapped to its own table such that both the attributes implemented by the class and its inherited attributes are mapped to the table. Following is an example to explain this technique:

[2]

References

[1] http://en.wikipedia.org/wiki/Object-relational_database
[2] http://www.agiledata.org/essays/mappingObjects.html
[3] www.adobe.com/newsletters/edge/october2008/articles/article2/images/fig2.jpg