Jump to content

ORM vs. active records


skaterdav85

Recommended Posts

I'd guess ORM is one common way to do Active Records... or perhaps the only one... To do Active Records you use ORM... in the same fashion that you use getters and setters to do the Open-Closed principle.

Link to comment
Share on other sites

So i asked the same question in the CodeIgniter forum and this was the reply I got:

There are 2 things to keep in mind. There is the ORM and AR design pattern and then there is the way it is implemented.Simply put: Active Record, properly defined, is a design pattern where an object is represented as a record on a table in a relational database.Data Mapper is very similar to Active Record but with one major design difference: The representation of an object is not necessarily a record from a table in a relational database. Hence, the keyword “Mapper” instead of “Record”. Data Mapper can implement Active Record albeit without the efficiencies that come with the assumption of the “one object - one record” constraint.This feature of the design is important when you start to consider data stores other than relational databases (e.g. external data stores accessed through REST, file based data storage or schema free databases). The rise of NoSQL, web applications and web services has fueled the need for more flexibility in the ORM layer.In CodeIgniter the Active Record Class is actually a SQL wrapper class, which simulates the Active Record Database pattern. It replaces the need to write SQL statements by using ‘object notation’. This ‘simulates’ the Active Record behaviour and is at the heart of much of the confusion for beginners: all the different ORM implementations for CodeIgniter that are available are in fact actually true Active Record implementations (i.e. they map an objoct to a database record).To clarify: ORM maps an object to a data ‘source’ (this does not have to be database). One of the implementations is the Active Record pattern (which maps a table row to an object).
So you're right. ORM is one way to do the Active Record design pattern, but ORM seems to be more flexible since it maps to a relational database or some other data source whereas AR relates to one record in a table.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...