Difference between Active Record and DAO?

Data Access Object (DAO) refers to an object in your data layer responsible for persisting a separate entity in your domain. Active Record is a specific method of doing a DAO where the class containing the values of a single row from a table is also responsible for queries, updates, inserts, and deletes to that table. The Active Record design pattern means your object has a one-to-one mapping with a table in your database.


A Data Access Object (DAO) is an interface dedicated to the persistence of a model/domain object to a data-source. Here's a reference.

The ActiveRecord pattern works in a similar fashion, but puts the persistence methods on the model object itself, while the DAO defines a discrete interface.

The advantage of the DAO pattern is:

  • Its easy to define another style of persistence, eg moving from a Database to cloud, without changing the underlying impelementation, while the external interface remains the same, therefore not affecting other classes.

  • The persistence concerns are modularized away from the main model object concerns.

The advantage of the ActiveRecord pattern is simplicity.