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 pricing

Real-world example

No real-world example available yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

Common mistakes

No common mistakes listed yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

Follow-up questions

No follow-up questions available yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

More Design Patterns interview questions

View all →