Data mapper pattern

In software engineering, the data mapper pattern is an architectural pattern. It was named by Martin Fowler in his 2003 book Patterns of Enterprise Application Architecture.[1] The interface of an object conforming to this pattern would include functions such as Create, Read, Update, and Delete, that operate on objects that represent domain entity types in a data store.

A Data Mapper is a Data Access Layer that performs bidirectional transfer of data between a persistent data store (often a relational database) and an in-memory data representation (the domain layer). The goal of the pattern is to keep the in-memory representation and the persistent data store independent of each other and the data mapper itself. This is useful when one needs to model and enforce strict business processes on the data in the domain layer that do not map neatly to the persistent data store.[2] The layer is composed of one or more mappers (or Data Access Objects), performing the data transfer. Mapper implementations vary in scope. Generic mappers will handle many different domain entity types, dedicated mappers will handle one or a few.

Implementations

Implementations of the concept can be found in various frameworks for many programming environments.

Java/.NET

Node.js / TypeScript

PHP

  • Atlas ORM (data mapper, table data gateway, query builder, and PDO wrapper)[3]
  • Doctrine2 Object Relational Mapper (ORM) and the Database Abstraction Layer[4]
  • Cycle ORM (PHP DataMapper ORM and Data Modelling Engine)[5]

Perl

Python

Ruby

  • DataMapper library (Actually this library implemented the Active Record design pattern, its successor, DataMapper 2 (now ROM) aimed to actually implement the design pattern it was named after)

Elixir

  • Ecto persistence framework

See also

  • Active record pattern – design pattern for software that stores in-memory object data in relational databases, with interface functions for insert, update and delete, and properties corresponding to the columns in the underlying database table
  • Object-relational mapping – Programming technique

References

This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.