Home / Learn Secure SQL / Microservices: Database per Service
Microservices: Database per Service
Why sharing one database across many services undermines isolation.
The idea, explained simply
In plain terms
The "database per service" pattern gives each microservice its own dedicated database (or at minimum, its own schema and account), rather than many services all reading and writing one shared database directly.
Why we use it
A shared database lets any service touch any other service's data directly, which undermines both the service-boundary isolation microservices are meant to provide and the least-privilege, per-service accounts covered earlier in this course.
Under the hood
Give each microservice its own database (or schema) and its own least-privilege account, and have services communicate through defined APIs/events rather than by directly querying another service's tables.
Real-world use
- Web application code review
- Backend development
- Database administration
This is primarily an architectural decision made early in a system's design, reinforcing (rather than replacing) the least-privilege, per-service-account ideas from the "Least privilege and access control" part of this course.
Quick quiz
1. Database-per-service mainly reinforces...
Isolation by architectural design.