Why does each microservice own its database, and what problem does that create?
Reviewed by Gurusankar M.
Short Answer
Each service owns its data so it can evolve its schema and scale independently — no other service may touch its DB directly (loose coupling). The cost: you can no longer do cross-service JOINs or ACID transactions, so you need API composition, events, and eventual consistency instead.
On this page
Concept Made Simple
Coffee Chat Question
“Why does each microservice own its database, and what problem does that create?”
Remember It Faster
Mind Map Answer
- Why
- independent schema + scaling, loose coupling
- Rule
- no service touches another's DB directly
- Cost
- no cross-service JOIN or ACID txn
- Replace with
- API composition / events / saga
Think Beyond the Expected
What If?
A report needs data from 4 services that each own their DB — how do you build it?
You can't JOIN across their databases. Options: API composition (query each service and join in memory), or maintain a read model / materialized view fed by their events (CQRS). For heavy reporting, the event-fed read model scales better than fan-out API calls.
Real World
The 'shared database' anti-pattern silently recouples services (one schema change breaks many); database-per-service is what makes independent deployment real, but it forces you to solve cross-service data via composition/events.
Interviewer's Expectation
Keywords they're listening for:
- data ownership/loose coupling
- no direct DB access by others
- lose cross-service JOIN/ACID
- API composition / events / CQRS
- shared-DB anti-pattern
Common Mistakes
- Sharing one database across services
- Doing cross-service JOINs via direct DB access
- Expecting ACID across services
Best Practices
- One database per service; access only via its API
- Use API composition or event-fed read models
- Accept eventual consistency for cross-service data
Follow-up Questions
- Why is a shared database an anti-pattern here?
- API composition vs CQRS read model for queries?
- How do you keep a read model in sync?
Continue Learning with AI
Take this question deeper with your favourite AI assistant. Pick a depth, copy the prompt, or open it directly — AI is your learning companion, not a shortcut.
Plain-language foundations
I'm preparing for a software engineering interview and want to understand this from scratch, as a beginner. Topic: Data Consistency (Microservices) Interview question: "Why does each microservice own its database, and what problem does that create?" Please: 1. Explain the core idea in simple, plain language, using an everyday analogy. 2. Define any technical terms you use. 3. Walk through one small, concrete example. 4. Finish with a single sentence I can easily remember. Keep the tone friendly and assume I'm new to this topic.
Was this answer helpful?
Affiliate links
Tools for Your Developer Workspace
Equipment for a comfortable, productive setup.
As an Amazon Associate I earn from qualifying purchases.
- MonitorView on Amazon : BenQ EW2790U 27-inch Monitor (opens in a new tab)
BenQ EW2790U 27-inch Monitor
- LaptopView on Amazon : Acer Aspire One Laptop (opens in a new tab)
Acer Aspire One Laptop
- Office ChairView on Amazon : Wakefit Gravita Ergonomic Office Chair (opens in a new tab)
Wakefit Gravita Ergonomic Office Chair