Microservice architecture with databases means giving each service its own data store rather than sharing one central database, so that services can be deployed, scaled, and changed independently. That is the direct answer, and it is the principle that separates a genuine microservice design from a distributed monolith. In practice, the pattern is usually called "database per service," and it comes with real costs: you lose easy cross-service joins, you inherit the complexity of distributed transactions, and you must solve data consistency and reporting in new ways. This article explains how the pattern works, why teams adopt it, where it breaks down, and what the main alternatives and workarounds are.

What "database per service" actually means

The core rule is ownership. Each microservice owns its data and is the only component allowed to read or write it directly. Other services reach that data through the owning service's API or through events it publishes. The physical implementation is flexible: a service can have its own schema inside a shared database server, its own dedicated database instance, or a completely different database technology.

That last point matters. Because services are decoupled at the data layer, a team can choose a relational database for transactional order data, a document store for a product catalog with variable attributes, and a search engine for a query-heavy read model. The pattern is sometimes described as polyglot persistence. It is not mandatory—many organizations standardize on one database engine for operational simplicity—but the architecture permits it, which a shared database does not.

A useful test: if two services can both write to the same table, you do not have a database per service, regardless of how the code is organized. You have a shared database with service-shaped code on top. That arrangement can work, but it is not what the pattern promises, and it recreates the coupling microservices are meant to remove.

Why the shared database undermines microservices

The appeal of a single database is obvious. Referential integrity is enforced by the database. Joins are cheap. Transactions span everything. Reporting is a SQL query away. The problem is that all of these conveniences are forms of coupling.

When multiple services share tables, a schema change in one service can break another. A long-running report query can lock tables and slow every service. A migration must be coordinated across teams, which reintroduces the release train that microservices were supposed to eliminate. The database becomes a de facto integration point, and its schema becomes an interface that everyone depends on but no one fully controls.

The database-per-service rule addresses this by making the schema a private implementation detail. A service can restructure its tables, change its database engine, or split its data without negotiating with anyone, as long as its external API contract stays stable. That independence is the actual goal; the separate database is the mechanism.

How services communicate across data boundaries

Once data is partitioned, services still need information from each other. Two broad styles cover most cases.

Synchronous calls. Service A calls service B's API to fetch or modify data. This is simple to reason about and gives immediate responses, but it creates runtime coupling: if B is slow or down, A is affected. Chained synchronous calls can produce latency that multiplies across the call path and can cascade failures. Use this style when the caller genuinely needs an answer now, such as validating that a customer exists before creating an order.

Asynchronous events. Service A publishes an event ("OrderPlaced") to a message broker, and interested services consume it and update their own data. This decouples services in time and lets each service maintain a local copy of the data it needs. The tradeoff is eventual consistency: consumers see the change after a delay, and you must handle duplicate deliveries, ordering, and failures. Most mature microservice systems lean heavily on events for cross-service data propagation and reserve synchronous calls for cases that require an immediate answer.

A common and useful hybrid is the API composition pattern: a service or a dedicated aggregator calls several services and combines their responses for a UI. That keeps each service's data private while still presenting a unified view to the user, at the cost of extra network calls and more complex error handling.

The hard problem: transactions across services

The single most common source of confusion is transactions. In a monolith with one database, a business operation like "place order, reserve inventory, charge payment" is one ACID transaction: it either fully succeeds or fully rolls back. With separate databases, there is no shared transaction boundary. Two-phase commit can technically span multiple databases, but it is fragile, slow, and poorly supported across heterogeneous stores and message brokers, so it is rarely the right answer in microservice systems.

The standard alternative is a saga: a sequence of local transactions, each in one service, with compensating actions that undo earlier steps if a later step fails. If payment fails after inventory was reserved, a compensating action releases the reservation. Sagas work, but they require you to design compensations for every step, and compensations are not always clean—you can refund a charge, but you cannot un-send a confirmation email. The system is eventually consistent rather than atomically consistent, and you must accept and manage intermediate states.

This is the price of the pattern, and it should be stated plainly: if your domain genuinely requires strict multi-table atomicity across what would otherwise be several services, those services may belong together. Splitting them apart and then trying to reconstruct ACID guarantees across the network is usually harder than keeping a well-bounded module in one service with one database.

Consistency, idempotency, and the outbox pattern

Eventual consistency introduces practical engineering requirements that teams often underestimate.

Because messages can be delivered more than once, consumers must be idempotent: processing the same event twice must not double-apply its effect. Common techniques include deduplicating on a unique event ID, or designing operations so that repeating them is harmless (setting a status to "shipped" is naturally idempotent; incrementing a counter is not).

A subtler problem is keeping a service's own database write and its published event in sync. If the service writes to its database and then crashes before publishing the event, downstream services never learn about the change. The widely used solution is the transactional outbox: the service writes the business change and the outgoing event to an outbox table in the same local transaction, and a separate process relays outbox rows to the broker. This guarantees that if the change is committed, the event will eventually be published, without needing a distributed transaction.

Reporting and analytics

Cross-service reporting is the second major pain point. When order data lives in the order service and customer data in the customer service, a simple "revenue by customer segment" report now spans two databases. Querying each service's API for every report is slow and couples the reporting tool to internal APIs.

The usual answer is to separate operational data from analytical data. Services publish events, and a separate pipeline or change-data-capture process feeds a data warehouse or read-optimized store where reporting runs. This keeps reporting load off the operational databases and lets analysts join data freely without violating service ownership, because the warehouse is a derived copy, not a source of truth. The cost is pipeline complexity and latency between operational changes and reporting availability.

Practical patterns that make the split work

Several established patterns reduce the friction of partitioned data:

Database per service as the baseline ownership rule. Saga for multi-service business transactions with compensations. Transactional outbox for reliable event publication. API composition or a backend-for-frontend layer to assemble read models for clients. CQRS (command-query responsibility segregation), where a service keeps a write model optimized for transactions and a separate read model optimized for queries, often fed by events. This is optional and adds complexity; use it where read and write loads genuinely differ. Shared-database anti-pattern awareness: some teams deliberately share a database for a small set of tightly related services early on, treating it as a stepping stone rather than a permanent design.

Where a shared database is still reasonable

Microservices are not a universal requirement. A shared database can be the correct choice in several situations:

Small teams and early-stage products. The coordination overhead of separate databases often exceeds the benefit until the system and organization grow. Tightly coupled domains. If two functions always change together and need strong transactional consistency, they are likely one service with one database. Read-heavy simple applications. If there is no real need for independent deployment or scaling, splitting the data adds cost without payoff.

The honest framing is that database per service trades operational simplicity for team autonomy and independent scalability. That trade is worth it at a certain scale and organizational structure, and it is not worth it below that threshold. Choosing microservices and then sharing one database gets you the costs of distribution without the benefits of decoupling.

A worked example

Consider an online store. The order service owns orders and order lines in a relational database. The inventory service owns stock levels. The payment service owns charges and refunds. The catalog service owns products in a document store because product attributes vary by category.

A customer places an order. The order service writes the order locally and records an outbox event. The outbox relay publishes "OrderPlaced." The inventory service consumes it, reserves stock, and publishes "StockReserved." The payment service consumes that, charges the card, and publishes "PaymentSucceeded"—or "PaymentFailed." If payment fails, the order service consumes the failure event and runs a compensating action: it marks the order as cancelled and emits "OrderCancelled," which the inventory service consumes to release the reservation.

Notice what is absent: no distributed transaction, no cross-database join, no service reading another service's tables. Every step is a local transaction plus an event. The system is temporarily inconsistent—an order can briefly exist in "pending" state while payment is in flight—and the design makes that intermediate state explicit rather than hiding it.

What to decide before committing

Before adopting database per service, settle three questions. First, what are the true service boundaries? Getting boundaries wrong produces chatty services and awkward sagas, and no amount of database separation fixes a bad decomposition. Domain-driven design's bounded contexts are a useful guide. Second, which business operations genuinely need atomicity across boundaries, and can they be expressed as sagas with acceptable intermediate states? Third, how will reporting and analytics get their data, and is there a plan for a warehouse or read model?

If those questions have clear answers, the pattern is sound. If they do not, a modular monolith with a single database—structured internally so modules could later be extracted—is often the more honest and more maintainable starting point. Microservices with databases are a powerful arrangement, but they are a solution to a coordination and scaling problem, not a default architecture.