What Is the Active Record Pattern?
In the active record pattern, an object wraps a single database row and exposes methods like save and delete directly on itself. Data and persistence behavior live together in the same class. It is simpler than a data mapper for straightforward applications but blurs the line between domain logic and storage.
Why it matters
Active record is quick to build with and easy to read for simple CRUD, which is why many web frameworks adopt it. As domain complexity grows, mixing persistence into objects can make rules harder to isolate and test.
Related guides
What Is a Data Mapper?A data mapper is a layer that moves data between objects and a database while keeping the two independent, so…
What Is the Repository Pattern?The repository pattern provides a collection-like interface for accessing domain objects, hiding the details…
What Is Lazy Loading in Data Access?Lazy loading defers fetching related data until it is actually accessed, avoiding upfront queries for associa…