# System Design Interview Prep: SQL vs NoSQL Databases

Aced (formerly Exponent) publishes a public search API over its indexed pages; the guide is at https://www.aced.io/agents/agent-access.

Source: https://www.aced.io/blog/sql-vs-nosql
Source observed: 2026-11-05T00:05:54.669Z
Last checked: 2026-11-05T00:05:54.669+00:00
Indexed: 2026-11-07T03:12:12.855+00:00

---

# System Design Interview Prep: SQL vs NoSQL Databases

We created this article for our system design interview preparation series. It explains how to choose between SQL and NoSQL databases according to the use case, then provides three practice exercises with solutions. For broader preparation, see our [System Design Interview Course](https://www.aced.io/courses/system-design-interviews?utm_source=blog&utm_campaign=blog-banner&src=blog). The article is tagged [Technical Program Management](https://www.aced.io/blog/tag/tpm).

**Author:** Kevin Jin  
**Last updated:** a month ago

## SQL Databases

SQL databases, also called relational databases, organize data in tables and use primary and foreign keys to define relationships between tables.

### (+) Relationships

SQL makes it easy to query relationships among data in multiple tables. Relationships help organize and structure large amounts of varied data, and SQL is powerful for fetching data while remaining relatively easy to learn.

### (+) Structured Data

SQL schemas define the columns and tables. The data model and format must be known before data is stored, which reduces room for potential error.

### (+) ACID

SQL databases support transactions and are ACID compliant:

- **Atomicity**
- **Consistency**
- **Isolation**
- **Durability**

A transaction is a group of statements executed atomically: either every statement executes, or none executes if one fails.

```sql
BEGIN TRANSACTION transfer_money_1922;
UPDATE balances SET balance = balance - 25 WHERE account_id = 10;
UPDATE balances SET balance = balance + 25 WHERE account_id = 155;
COMMIT TRANSACTION;
```

This example transfers **$25** from one account balance to another.

### (-) Structured Data

Because columns and tables must be created ahead of time, SQL databases take longer to set up than NoSQL databases. SQL is also less effective for storing and querying unstructured data whose format is unknown.

### (-) Difficult to Scale

The relational nature of SQL databases makes horizontal scaling difficult. For read-heavy systems, we can provision multiple read-only replicas through master-slave replication. For write-heavy systems, the usual alternative is vertical scaling, which is generally more expensive than adding servers.

![Master-Slave Replication diagram](https://storage.ghost.io/c/a5/f5/a5f5c2f0-4c62-43c7-891b-662a0b6d68b3/content/images/C-M1frU1Q3PoSwLzwtYx7NMSIOvcu2skfowY5clCODvM898y-ApT52l8nW0ged2gpE2ot-ZNlKwg3U_dRKwh0L-B70HVfZc7wnwXIwNlCqOU0np_GNsMQo4xVWdfp_LDEZnJVrXY.png)

*Master-Slave Replication*

Increasing the number of read replicas creates a consistency-versus-availability trade-off. More read servers increase availability but can reduce consistency when updates are asynchronous, because a request has a higher chance of reaching a replica with stale data. This follows the CAP theorem.

Horizontal scaling for write-heavy SQL databases is not impossible. Google Spanner and CockroachDB demonstrate that it can be done, but it is challenging and produces a highly complex database architecture.

**Popular SQL database examples:** MySQL, PostgreSQL, Microsoft SQL Server, Oracle, and CockroachDB.

## NoSQL Databases

NoSQL databases generally do not support table relationships. Data is commonly stored in documents or as key-value pairs.

### (+) Unstructured Data

NoSQL databases are more flexible and simpler to set up, making them a better choice for unstructured data.

### (+) Horizontal Scaling

Without table relationships, NoSQL data can be sharded across multiple data stores to create a distributed database. This makes horizontal scaling easier and allows very large amounts of data to be stored without buying one expensive server. NoSQL can support both read-heavy and write-heavy systems.

When data is distributed across shards or servers, hashing and consistent hashing help determine which shard or shards should receive an application query.

![MongoDB query-router diagram](https://storage.ghost.io/c/a5/f5/a5f5c2f0-4c62-43c7-891b-662a0b6d68b3/content/images/6Lya9sGKWGbcNh4QKiraQgCWtvcG3E-vgpNGy5Lth7OCt3zhKHAyDbUeCVRy78u-h_gLnpoGLz-kIlK7y8J9iGT-EKPXV0xnR8jNpB1xTFLiXtUqtyD_u6TwUbMHJEJ9zB92oOBo.png)

In MongoDB, a query router acts as a reverse proxy: it accepts a query, routes it to the appropriate shard or shards, and returns the response to the calling application. Its role is similar to that of a load balancer.

### (-) Eventual Consistency

NoSQL databases are commonly designed for distributed use cases. Write-heavy systems can use multiple write shards for the same data partition through peer-to-peer replication, but this can sacrifice strong consistency. After a write reaches one shard in a distributed NoSQL cluster, a short delay may occur before the update reaches other replicas. A read from a replica during that interval can return stale data.

Eventual consistency is not unique to NoSQL; it can also result from distributed databases generally, including master-slave replication used with SQL or NoSQL. A single-shard NoSQL database can be strongly consistent. To fully benefit from NoSQL scalability, however, the database is typically configured as a distributed cluster.

**Popular NoSQL database examples:** MongoDB, Redis, DynamoDB, Cassandra, and CouchDB.

## Short Exercises

### Question 1

We need to build a service for tens of millions of Amazon shoppers. It stores each shopper’s past **100 viewed products** for targeted product advertisements. The data may be a little out of date.

- **Hint:** The prompt says stale data is acceptable.
- **Hint 2:** A lot of data must be stored.
- **Solution:** **NoSQL**

### Question 2

A company is experiencing scaling problems because many new microservices read customer metrics from its main SQL database. We need a cache service in front of that database. If a query has not been cached in the last **10 minutes**, the cache queries the database and stores the result. Otherwise, it returns the cached result without querying the main database.

- **Hint:** The cache must look up a result by the SQL query string.
- **Hint 2:** The stored data is non-relational.
- **Solution:** **NoSQL**

### Question 3

We need to build a PayPal service that lets users apply for loans through the app. The database stores loan applications, including the loan amount, the user’s current balance, and prior transaction history.

- **Hint:** This financial application requires strong data consistency.
- **Hint 2:** The loan, balance, and transaction data have relationships.
- **Solution:** **SQL**

## Continue preparing with Aced

- [Browse technical program manager interview questions](https://www.aced.io/questions?role=tpm&src=blog) and answers from real candidates.
- [Book time with a Technical Program Manager coach](https://www.aced.io/coaching?role=tpm). Coaching options include mock interviews, career coaching, and resume review. [Browse coaches](https://www.aced.io/coaching?role=tpm&src=blog).
- [Create your free account](https://www.aced.io/signup?src=blog).

We are Aced, formerly Exponent. We provide free interview guides, insider tips, courses, mock interviews, coaching, resume review, and other resources for technical and business interviews.

## Related Courses

### [Software Engineering Interview Prep Course](https://www.aced.io/courses/software-engineering)

![Software Engineering Interview Prep Course](https://images.ctfassets.net/x78yjrjc11pq/4VkuYewBHUFIVUS5oJDW5h/02e833439b1289f25f38f13f81cbdca3/adobe_stock_optimized.jpeg?w=800&h=800)

**5 courses · 41,700 students**

Prepare for software engineering roles at Google, Amazon, Microsoft, Meta, Apple, and other top companies. The course includes mock interviews, frameworks, advice from senior candidates, and practice in data structures, algorithms, system design, people management, behavioral interviews, and more.

### [Technical Program Management Interview Prep Course](https://www.aced.io/courses/tpm)

![Technical Program Management Interview Prep Course](https://images.ctfassets.net/x78yjrjc11pq/3cFr05VXO4mAcuqrI861Ob/c84a83a29ab27ac67309f3e3658805da/Technical_Program_Manager_Interview_Prep_Course.jpeg?w=800&h=800)

**5 courses · 18,700 students**

Prepare for program management roles at Google, Meta, Amazon, Microsoft, Apple, and other top companies. The course covers mock interviews, frameworks, advice from senior candidates, system design, program sense, cross-functional projects, behavioral interviews, and more.

## Related Blog Posts

- [What Is The Role of a Technical Program Manager?](https://www.aced.io/blog/what-is-the-role-of-a-technical-program-manager)
- [15 Teleconferencing Tips for a Successful Remote Interview](https://www.aced.io/blog/15-teleconferencing-tips-for-a-successful-remote-interview)
- [Differences between PM (Product Manager) vs TPM (Technical Program Manager)](https://www.aced.io/blog/pm-vs-tpm)
- [Software Engineer Resume: Real Examples and How to Write Yours (2026)](https://www.aced.io/blog/software-engineer-resume)

---

[Read this page’s summary](https://www.aced.io/agents/api/public/v1/page-tldr?url=https%3A%2F%2Fwww.aced.io%2Fblog%2Fsql-vs-nosql&trace=t_679ff9ab98f3)

## Ask a follow-up about this page

Need a more specific answer? Ask the exact question you have. It returns a fresh, cited answer from Aced (formerly Exponent)’s knowledge base. No account or API key required.

Open this URL with your own question, URL-encoded. Include your question in q. All research inputs are optional; no account or setup.

`GET https://www.aced.io/agents/agent/faq?q={question}&trace=t_679ff9ab98f3`

[Tool guide and examples](https://www.aced.io/agents/agent-access) · [OpenAPI](https://www.aced.io/agents/api/public/v1/openapi.json) · [Page TLDR form](https://www.aced.io/agents/agent-tools/page-tldr?url=https%3A%2F%2Fwww.aced.io%2Fblog%2Fsql-vs-nosql). Opening a form does not execute a tool.