Easy👤 3-5 years👤 8-15 years 1 min read

Why does each microservice own its database, and what problem does that create?

Asked inAmazonMicrosoftDeloitte
#database per service#data ownership#coupling#joins#consistency
Report issue

⚡ 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.

Coffee Chat Question

Concept Made Simple

Why does each microservice own its database, and what problem does that create?

🧠Mind Map Answer

Remember It Faster

Whyindependent schema + scaling, loose coupling
Ruleno service touches another's DB directly
Costno cross-service JOIN or ACID txn
Replace withAPI composition / events / saga

🔥What If?

Think Beyond the Expected

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 couplingno direct DB access by otherslose cross-service JOIN/ACIDAPI composition / events / CQRSshared-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

  • 1Why is a shared database an anti-pattern here?
  • 2API composition vs CQRS read model for queries?
  • 3How do you keep a read model in sync?

🧩Related Technologies

CQRSAPI compositionevent sourcing

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.
Open inChatGPTGeminiClaude

Was this answer helpful?

Support our platform by exploring our recommended products.

As an Amazon affiliate, purchases through these links may earn us a small commission — at no extra cost to you. It helps keep Full Stack Interview Guru free.

Related Questions