← Back to microservices patterns mapdata
🗄️
Microservices Pattern
Database per Service
Each service owns its database and no other service reads or writes it directly.
Detailed Description
Data ownership is one of the strongest service boundaries. A service API becomes the only allowed access path.
This enables independent evolution but pushes cross-service read needs into composition, projections, or events.
Visual Diagram
Data Ownership Model UserService → [PostgreSQL db_users] OrderService → [MongoDB db_orders] ProductService → [Redis db_products] SearchService → [Elastic db_search] ✗ OrderService cannot query db_users directly ✓ OrderService calls UserService API instead
Tradeoffs
Pros
Loose coupling, independent schema changes
Cons
Cross-service queries become harder
Examples: Microservices data ownership best practice