seniorDesign Patterns
Active Record vs Data Mapper Pattern?
Updated Apr 28, 2026
Short answer
Two distinct patterns for mapping object-oriented models to relational databases.
Deep explanation
Active Record puts data access logic directly inside the domain entity. The entity knows how to save itself (e.g., user.save()). Data Mapper completely separates the in-memory objects from the database. A separate Mapper class handles the saving, keeping the domain entity pure (e.g., repository.save(user)).
Unlock with a Pro subscription to view this section.
View pricingReal-world example
No real-world example available yet.
Unlock with a Pro subscription to view this section.
Upgrade to ProCommon mistakes
No common mistakes listed yet.
Unlock with a Pro subscription to view this section.
Upgrade to ProFollow-up questions
No follow-up questions available yet.
Unlock with a Pro subscription to view this section.
Upgrade to Pro