Difference between Model and Entity

모델과 엔티티의 차이에 대해서 알아보자.

Doohyeon Kim
Doohyeon.kim
3 min readFeb 14, 2023

--

Domain models and entities are similar concepts, but with the following differences:

  • Entity: Represents the most basic unit of data in an application, such as a user, product, or order. Entities are typically connected to a data source, such as a database or an external API. They are the lowest level in the domain and are used to interact with data sources.
  • Domain Model: Represents the conceptual expression of business rules and concepts in a domain. Unlike entities, domain models are not dependent on specific data. Instead, they use the data from entities to implement business logic. In other words, domain models are objects that build on entities to implement business logic.

For example, in an e-commerce app, a product entity might have attributes such as product ID, name, and price. On the other hand, a domain model might handle business logic related to the product, such as the quantity ordered or the total amount paid.

In summary, entities represent data objects, while domain models are objects responsible for implementing business logic.

도메인 모델과 엔티티는 서로 비슷한 개념이지만, 다음과 같은 차이가 있다.

  • 엔티티: 애플리케이션에서 가장 기본적인 데이터 단위를 나타낸다. 예를 들어, 사용자, 상품, 주문 등이 될 수 있으며, 보통 데이터베이스와 연결되어 있다. 엔티티는 도메인에서 가장 낮은 레벨이며, 데이터베이스나 외부 API와 같은 데이터 소스와 상호 작용하는 데 사용된다.
  • 도메인 모델: 도메인 모델은 비즈니스 규칙과 도메인에 대한 개념적인 표현을 나타낸다. 엔티티와 다르게 도메인 모델은 특정한 데이터에 종속되지 않는다. 대신, 도메인 모델은 엔티티의 데이터를 가지고 비즈니스 로직을 구현한다. 즉, 도메인 모델은 엔티티를 기반으로 하지만 비즈니스 로직을 구현하는 객체다.

예를 들어, 인터넷 쇼핑몰 앱에서 상품 엔티티는 제품 ID, 제품 이름, 가격 등의 속성을 가질 수 있다. 반면 도메인 모델은 주문된 상품의 수량, 결제 금액 등과 같은 상품과 관련된 비즈니스 로직을 담당할 수 있다.

즉, 엔티티는 데이터를 나타내는 객체이며, 도메인 모델은 비즈니스 로직을 담당하는 객체다.

--

--

Doohyeon Kim
Doohyeon.kim

Developer, SW Engineer, Product Manager. Expert for startup company.