Understanding the Relationship Between Domain-Driven Entities and Tables

Asked 2 years ago, Updated 2 years ago, 116 views

Domain-driven entities recognize that there are cases where tables do not always match.

With that in mind, would it be okay to "hold data in multiple tables with one entity" for example?

Also, is there no problem that the data processed in the repository spans multiple tables?I would also like to ask a question about

Prerequisites

  • Unable to modify table structure along entity

  • (I can't define entities freely due to infrastructure reasons)

Cannot (hard to) change table structure along entity

(Infrastructure cannot define entities freely)

Examples of simple table structures

User Settings Table 1: Target 1, Target 2
User Settings Table 2: Target 3, Target 4
User Configuration Table 3: Target 5, Target 6

domain-driven-design architecture

2022-09-30 19:49

1 Answers

If a domain model chooses a design policy, such as a clean architecture or hexagonal architecture, that does not depend on external technical elements (as is usually the case), the domain model does not care how it is perpetuated.
So it doesn't matter whether you put one entity in a table of the same structure or divide it into multiple tables.
Rather, it is possible to design tables freely considering the performance of because there is no dependence from the domain model.


2022-09-30 19:50

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.