.NET Architecture & System Design Interview Question #108
Why should a microservice own its data?
Microservices, API Gateway, Service Communication & Event-Driven Architecture Mid-Level Intermediate
Quick Interview Answer
Independent data ownership prevents services from becoming tightly coupled through a shared database schema. A service can change its internal schema without requiring every other service to coordinate.
Detailed Explanation
Independent data ownership prevents services from becoming tightly coupled through a shared database schema. A service can change its internal schema without requiring every other service to coordinate.
Other services should access the owning service through contracts such as APIs or events. This creates distributed consistency challenges, but preserves autonomy and prevents hidden cross-service dependencies.
Code Example
Orders Service -> Orders DB
Billing Service -> Billing DB
Avoid:
Orders and Billing directly editing
the same tables.