This question is to understand the pros & cons for keeping the DAO's with the service or as a separate package being consumed by the services.
Consider a micro-service architecture. Let's say I have 5 different services which constitute a System. Then there is a Database (MySQL or Amazon DynamoDB) which these services communicate with.
There appear to be 2 ways to design the
Data Access Layer
Design a separate package which encapsulates all the DAO's for the tables.
Each service can add a dependency on this DAL and talk to the database. This would result in any changes being restricted to this package only. But would result in re-deployment in each micro service since all of them consume this DAL.
Integrate the DAO's within each service itelf.
This would lead to only the relevant service being changed in case any database layer changes occurs (except thing like re-architecturing, or other system wide changes).
Both approaches seem fine to me. Could you guys share some inputs on them - which one to pick under which scenario, pros and cons of the 2 appproaches?