Micro services Shared Database Pattern
Database should almost never be shared among services.
The disadvantages are obvious:
- We decline ourselves the opportunity to decide what to share and what not, i.e. no information hiding.
- It hard to know which part of the database is safe to change.
- It hard to know who controls the data. A micro service is combination of behavior and state, encapsulating one or more state machines. If the behavior that affects the state is spread across the system, making sure that the state machine can be implemented properly is a tricky business.
An exception to this rule no database sharing rule is static reference data, which is usually read-only to the services. Changes to structure is infrequent and usually performed as an administrative task.