Everybody building a web application with a modern framework, is already probably using an ORM (Object-Relational Mapping). Most frameworks include one out of the box. But digging deeper into the subject, ORMs do vary from each other, and some cases, very significantly.
Most variations are coming from two main approaches: Active Record and Data Mapper. I’ve heard the terms for a long time, but today decided to look into the meaning and the actual difference.
The two approaches seem very similar. The difference is described in a multitude of articles online. I particularly liked this one. In essence, Active Record is a better choice for simpler, CRUD-based applications. Data Mapper, on the other hand, is better for domain-specific applications, as it provides another level of abstraction between the domain objects and the persistence layer.
Most of my work these days is done with CakePHP framework, which I now thought uses the Active Record pattern. But it turns out that CakePHP ORM so powerful, because it’s more than just one of those:
The CakePHP ORM borrows ideas and concepts from both ActiveRecord and Datamapper patterns. It aims to create a hybrid implementation that combines aspects of both patterns to create a fast, simple to use ORM.
It looks like I need to do some learning and dig deeper into the subject. Pointers are welcome.