The data layer handles how an application fetches and stores data, keeping those mechanics separate from decisions about what the application should do. It commonly sits within the infrastructure layer and can provide implementations for interfaces defined by the application or domain layers. section 4.2.3
Use this boundary to sort responsibilities:
- Put database operations—such as using an ORM or SQL to fetch or store data—in the data-access code. section 4.2.3
- Keep decisions about what to do with the data in business logic, not in a repository. Shape repositories around use cases rather than individual database rows. section 5.3.5
- Keep business policies such as atomicity or retries inside the core or an application service, where adapters do not hide them. section 5.3.5
A separate Data Access Layer can be useful in a large system, alongside infrastructure code for concerns such as email or external APIs. These are sibling parts: a message to an email service need not pass through the database layer. Layers describe code organization; tiers describe physical deployment, so several layers can run on one server or across multiple machines. section 4.2.3 section 4.2.3
Treat persistent databases differently from replaceable application code: a live database cannot simply be destroyed and rebuilt without risking its data, so changes require careful management. section 9.8.3







