eloquent를 액티브 레코드 패턴의 ORM이라고 정의하는데, 이 패턴에 대해서 간단하게 짚고 넘어가자.
this pattern's software store in-memory object data in relational databases.
2003년 마틴파울러에 의하여 정의되었다.
이 패턴은 ORM에서 흔히 사용된다.
장점
raw SQL queries.를 사용하지 않아도 된다.
단점
1. 테스트가 어려워서 모킹이나 DI가 이용된다.
2. scp와 soc를 따르지 않는다.
3. 분산시스템이 적용되지 않는다.
The Active Record pattern is a design pattern that is used in object-relational mapping (ORM) and is commonly used in web development. It is a design pattern that provides an object-oriented interface to a database, allowing you to interact with your database using objects instead of raw SQL queries.
In the Active Record pattern, each record in a database table is represented as an instance of a class, and each class is associated with a database table. The class includes methods for creating, retrieving, updating, and deleting records in the database, and these methods are used to perform the relevant database operations.
For example, consider a database table named users that contains information about users in a web application. In an Active Record implementation, you would create a class named User that represents a user record, and the class would include methods such as save, update, delete, and find, which perform the relevant database operations.
One advantage of using the Active Record pattern is that it can simplify the process of working with a database and can make it easier to write and maintain your code. It also promotes loose coupling between your code and the database, as you can change the underlying database schema without affecting the code that uses the Active Record classes.
However, the Active Record pattern can also lead to issues with performance and scalability, as it can result in an increased number of database queries, and the increased complexity of the code can make it harder to debug and maintain. It is important to use the Active Record pattern with care and to consider alternative approaches, such as the Data Mapper pattern, when building web applications.
참고
https://en.wikipedia.org/wiki/Active_record_pattern
https://martinfowler.com/eaaCatalog/activeRecord.html