API / Microservices Design Patterns Interview Questions
What is the Database per Service pattern and what problem does it solve?
The Database per Service pattern mandates that each microservice owns its own persistent data store exclusively. No other service may directly read or write to that store — access is only possible through the owning service's published API. The store may be a separate schema in the same RDBMS engine, a fully separate server instance, or an entirely different database technology chosen to match the service's data model and access patterns.
The core problem it solves is structural data coupling. When services share a database, a schema change in one table can silently break every other service that reads it. Two teams must coordinate every deployment that touches shared tables, making independent deployment — a foundational goal of microservices — impossible in practice.
Benefits enabled by this pattern:
- Independent deployment — schema migrations are scoped to a single service. No cross-team release coordination required.
- Polyglot persistence — each service chooses the database best suited to its workload: relational for orders, document store for product catalog, time-series for IoT metrics, graph for social connections.
- Fault isolation — a database outage in one service does not directly cascade to other services that have separate stores.
- Independent scaling — a high-read service can add read replicas or a caching layer without affecting other services' data infrastructure.
The trade-off is that cross-service queries cannot use SQL JOINs. Queries that used to be a single SQL statement across multiple tables must now be composed at the application level using the API Composition pattern (Q14) or a dedicated CQRS read model (Q12). Cross-service writes must use the Saga pattern (Q10) rather than a single ACID transaction.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
