Each service owns its data and nobody else touches it, so services can change and scale on their own.
Database per service means each microservice has its own private data store. No other service reads or writes its tables directly. They can only ask the owner, through its API or its events.
In a microservices system we want each service to change and be released on its own. That is hard if two services read the same table. The moment Customers renames a column, Orders and Billing break. The database became a secret shared contract, and nobody wrote it down.
The fix is a rule: a service owns its data. The Orders service has an orders database. The Customers service has a customers database. If Orders needs a customer name, it must ask Customers (an API call), or listen to events from Customers and keep a small copy of what it needs.
| Level | What is separate | Good | Careful |
|---|---|---|---|
| Private tables | Same database, but each service has its own tables and a rule not to touch others | Cheap and simple to start | Only a rule. Someone will break it. |
| Schema per service | Same server, separate schemas with separate logins | Rules are enforced by permissions | Shared server resources: a heavy service slows the others |
| Database per service | Separate database instance per service | Real isolation and independent scaling | More databases to run, back up and pay for |
| Server per service | A different server (or type of database) per service | Full freedom and fault isolation | Highest cost and most to operate |
| Way | How it works | Good for | Watch out |
|---|---|---|---|
| API call | Ask the owning service each time | Data that must be fresh | Adds a network call and depends on the other service being up |
| API composition | One place calls several services and combines the answers | Pages and reports built from many services | Slow if it makes many calls in a row. See API Composition. |
| Local copy from events | The owner publishes changes. You store only what you need. | Reads that must be fast and survive the other service being down | The copy can lag. See Outbox Pattern and Change Data Capture. |
| CQRS read model | A separate store built from events, shaped for queries | Complex queries across services | More moving parts. See CQRS. |
| Analytics store | Copy everything into a warehouse for reports | Company-wide reports | Not for live user requests. See ETL Pipelines. |
Illustrative numbers: a database query takes 5 ms and a call between services takes 20 ms. The page has 12 different customers for 20 orders.
| Term | Meaning in easy words |
|---|---|
| Database per service | A pattern where each microservice owns a private data store |
| Shared database | Several services using the same tables, which hides tight coupling |
| Polyglot persistence | Using different kinds of database for different services, each the best fit |
| Service API | The only public way to read or change another service's data |
| Data ownership | One service is the single source of truth for a piece of data |
| API composition | Building one answer by calling several services and combining the results |
| Local copy (replica) | A small, read-only copy of another service's data, kept up to date by events |
| Eventual consistency | Copies agree after a short delay, not at the same instant |
| Saga | A chain of local transactions with undo steps, used instead of one big transaction |
| Schema | The layout of a database: tables, columns and their types |
| Coupling | How much one part must change when another part changes |
| Choice | We gain | We lose |
|---|---|---|
| Shared database | Easy joins, simple transactions, fast start | Hidden coupling, forced coordinated releases, shared failures |
| Database per service | Independence and fault isolation | Cross-service queries and transactions get harder |
| Read through an API | Always fresh data | Extra network calls, and a dependency on the owner being up |
| Keep a local copy | Fast reads that survive an outage | Lag, storage, and an event pipeline to maintain |
| Many database types | The right tool for each service | More skills to learn and more systems to run |
| Saga instead of a transaction | Works across services | Temporary inconsistency and undo logic to write |