# Active Record Pattern

I have been using Active Record (opens new window) in the context of Rails applications for a while now. However, I just recently learned that there there is something called Active Record Pattern that inspired this library.

It was first described by Martin Fowler (opens new window) as the following:

An object that wraps a row in a database table or view, encapsulates the database access, and adds domain logic on that data.

There are two parts to this object: the actual data represented as a distinct field in the object for every column in the SQL table. And the logic to access or update that data from the underlying (relational) database.

Active Record objects are tightly coupled with database tables and often have business logic that allows for interacting with said tables. However, this also means that any modifications to the objects might also require changes to the database design.

An alternative is the Data Mapper Pattern also described by Martin Fowler.

Last Modified: 9/21/2020, 12:46:10 PM