In a nutshell
In-memory objects (e.g., a Java / PHP object) and relational databases (e.g., MySQL) have different mechanisms for structuring and representing data. Often, object representations such as collections or inheritance don’t map neatly to relational databases.
The Data Mapper is the layer of software that transfers data between the two structures whilst keeping them isolated. The in-memory objects don’t need to know about the database and vice-versa.
Other notes
- Include link to example implementation of a DataMapper. Should be able to find it in Symfony’s ORM.
Sources
- Data Mapper – Martin Fowler
- Patterns of Enterprise Application Architecture (p. 165)