Software Design

Active Record vs Data Mapper: Architecture Trade-Off

UML Class Diagrams · made in Skemio

UML class diagram contrasting Active Record User entity with Data Mapper architecture consisting of pure User entity, UserRepository, and database connection.
UML class diagram contrasting Active Record User entity with Data Mapper architecture consisting of pure User entity, UserRepository, and database connection.

What it shows

  • Active Record couples database schema directly to business entities.
  • Data Mapper isolates domain logic from persistence and schema changes.
  • Choose Active Record for rapid CRUD; use Data Mapper for complex domains.

The takeaway

Decouple persistence when domain rules outgrow table columns.

More uml class diagrams