SQL vs NoSQL Questions with Answers

14 practice questions on SQL vs NoSQL (System Design) with answers and step-by-step solutions. Try 10 samples below, then practise all 14 free in the AptiNest app.

Sample questions

Question 1Easy

Time-series databases are optimised for:

  1. Multi-table joins
  2. Graph traversals across many relationship hops
  3. Storing binary images
  4. Timestamped append-heavy data like metrics

Answer: D. Timestamped append-heavy data like metrics

Explanation

They compress sequential timestamped points and make range aggregations cheap.

Step-by-step solution

  1. Time-series data arrives as timestamped points (metrics, sensor readings).
  2. It is mostly appended, rarely updated, and queried by time range.
  3. Time-series databases compress and index by time for exactly this pattern.

Why the other options are wrong

  • A. Joins are a relational strength, not a time-series one.
  • B. Multi-hop traversals suit graph databases.
  • C. Binary images belong in object storage.

Tip: Keywords 'metrics', 'sensors', 'over time' point to a time-series DB.

Question 2Easy

Which database type is commonly used to power full-text product search?

  1. A message queue
  2. A graph database
  3. A columnar file format such as Parquet stored on object storage
  4. A search engine such as Elasticsearch

Answer: D. A search engine such as Elasticsearch

Explanation

Search engines build inverted indexes for fast text queries, ranking and filtering.

Step-by-step solution

  1. Product search needs tokenising, ranking and typo tolerance.
  2. Search engines build inverted indexes for this.
  3. Elasticsearch is the typical choice.

Why the other options are wrong

  • A. A message queue moves messages, it does not search.
  • B. Graph databases are for relationships.
  • C. Parquet on object storage suits analytics scans, not interactive text search.

Question 3Easy

Which use case most naturally fits a graph database?

  1. Logging server metrics every second from thousands of machines
  2. Storing monthly payroll records
  3. Caching session tokens
  4. Friends-of-friends recommendations in a social network

Answer: D. Friends-of-friends recommendations in a social network

Explanation

Graph databases store relationships as first-class edges, making multi-hop traversals efficient.

Step-by-step solution

  1. Graph databases store nodes and relationships directly.
  2. Friends-of-friends needs several relationship hops.
  3. Graph DBs traverse hops without expensive joins.

Why the other options are wrong

  • A. Metrics logging is a time-series workload.
  • B. Payroll is tabular relational data.
  • C. Session tokens suit a key-value cache.

Question 4Easy

A banking ledger needs multi-row transactions and strict integrity constraints. The usual default choice is:

  1. A document store with no transactions
  2. A key-value cache
  3. A relational database
  4. A CDN

Answer: C. A relational database

Explanation

Financial records need ACID guarantees and constraints that relational databases provide natively.

Step-by-step solution

  1. A banking ledger needs multi-row transactions.
  2. It also needs strict integrity constraints.
  3. Relational databases provide ACID transactions and constraints natively.
  4. So the usual default is a relational database (option C).

Why the other options are wrong

  • A. A document store with no transactions cannot give multi-row atomicity by default.
  • B. A key-value cache has no multi-row transactions or constraints.
  • D. A CDN serves cached content and does not store ledgers.

Tip: For money and multi-row integrity, start with a relational database.

Question 5Medium

Modern relational databases like PostgreSQL support JSON columns. What does this show?

  1. The line is blurry; choose by access patterns and guarantees
  2. Document stores are obsolete
  3. JSON columns can store only strings and must be parsed by the application on every read
  4. SQL databases are now schema-less

Answer: A. The line is blurry; choose by access patterns and guarantees

Explanation

Many databases mix models; the decision rests on consistency needs, query patterns and scaling, not labels.

Step-by-step solution

  1. PostgreSQL has JSON columns, so one database can hold document-like data.
  2. Document stores and SQL databases now overlap in features.
  3. The choice depends on consistency needs, query patterns and scaling.
  4. So the lesson is that the line is blurry (option A).

Why the other options are wrong

  • B. Document stores are not obsolete; the JSON column does not replace them.
  • C. JSON columns store structured JSON values, not only strings, and can be queried.
  • D. A JSON column does not make the whole SQL database schema-less.

Tip: Pick a database by access pattern and guarantees, not by its label.

Question 6Medium

What does BASE stand for in the NoSQL context?

  1. Basically Available, Soft state, Eventually consistent
  2. Balanced, Available, Sharded, Encrypted
  3. Backup, Archive, Store, Erase
  4. Bounded, Atomic, Serializable, Exact

Answer: A. Basically Available, Soft state, Eventually consistent

Explanation

BASE describes systems that prioritise availability and accept temporary inconsistency, in contrast to ACID.

Step-by-step solution

  1. BASE is the NoSQL counterpart to ACID.
  2. It stands for Basically Available, Soft state and Eventually consistent.
  3. It accepts temporary inconsistency in return for availability.
  4. So BASE is option A.

Why the other options are wrong

  • B. Balanced, Available, Sharded, Encrypted is not the BASE acronym.
  • C. Backup, Archive, Store, Erase is not the BASE acronym.
  • D. Bounded, Atomic, Serializable, Exact is not the BASE acronym.

Tip: ACID for strong consistency; BASE for availability with eventual consistency.

Question 7Medium

'Schema-on-read' in document databases means:

  1. Structure is interpreted when reading, not enforced on write
  2. Reads are slower than writes by design
  3. The database rejects documents that do not match a registered schema
  4. The schema is stored in a separate SQL table

Answer: A. Structure is interpreted when reading, not enforced on write

Explanation

Documents can vary in shape; the application must handle differences, which adds flexibility but shifts validation to code.

Step-by-step solution

  1. Schema-on-write checks a document's shape when it is saved.
  2. Schema-on-read keeps the shape open and interprets it when it is read.
  3. So documents can vary, and the application must handle the differences.
  4. So schema-on-read means structure is read and interpreted, not enforced on write (option A).

Why the other options are wrong

  • B. Reads and writes have no fixed speed ratio by design; this is not the meaning.
  • C. A database that rejects non-matching documents is schema-on-write.
  • D. The schema is not stored in a SQL table in this sense.

Tip: Schema-on-read moves validation from the database into the application code.

Question 8Medium

Why do many NoSQL stores favour denormalised data models?

  1. To reduce disk usage
  2. To answer reads from one partition without joins
  3. Because they cannot store numbers
  4. Because normalisation is not allowed in JSON documents by the specification

Answer: B. To answer reads from one partition without joins

Explanation

Distributed joins are expensive; storing data shaped for the query lets one lookup answer it.

Step-by-step solution

  1. Joins across partitions or nodes are expensive in distributed stores.
  2. Data is stored in the shape each query needs, often duplicated.
  3. Then one lookup in one partition answers the read without a join.
  4. So the reason is to answer reads from one partition without joins (option B).

Why the other options are wrong

  • A. Duplicating data usually uses more disk, not less.
  • C. NoSQL stores can store numbers; that is not the reason.
  • D. JSON has no rule against normalisation; the choice is a design trade-off.

Tip: In distributed NoSQL, model data around the query so one partition answers it.

Question 9Medium

Polyglot persistence means:

  1. Translating SQL queries into many programming languages automatically
  2. Using different database types for different needs
  3. Storing every record in every database
  4. Using one database for all services

Answer: B. Using different database types for different needs

Explanation

For example, Postgres for orders, Redis for sessions, Elasticsearch for search and a graph DB for recommendations.

Step-by-step solution

  1. Different data have different needs.
  2. Use the best-fit DB for each.
  3. That is polyglot persistence.

Why the other options are wrong

  • A. Unrelated to programming languages.
  • C. That would be replication everywhere.
  • D. That is the opposite.

Question 10Hard

In a wide-column store like Cassandra, how should tables usually be designed?

  1. In third normal form with many joins
  2. With one row per database
  3. With a single global secondary index for every column in the table
  4. Around the queries you need, often a table per access pattern

Answer: D. Around the queries you need, often a table per access pattern

Explanation

Cassandra lacks joins; you model data for each query and pick partition keys that keep each query within one partition.

Step-by-step solution

  1. Cassandra has no joins.
  2. So each query needs its own table, shaped around that query.
  3. Partition keys are chosen so each query stays in one partition.
  4. So the usual design is a table per access pattern (option D).

Why the other options are wrong

  • A. Third normal form with many joins does not suit Cassandra, which has no joins.
  • B. One row per database is not a design pattern; Cassandra tables hold many rows.
  • C. A global index on every column is not the way to model Cassandra tables.

Tip: In Cassandra, start from the queries and design one table per query.

Practise all 14 questions free

The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.

Open this topic in the app →

Related topics

See all System Design topics · All topics