Databases & SQL Interview Questions: SQL vs NoSQL

Reviewed by Mark Dickie · Last updated

17 questions on this page you can answer and see marked on the spot. Go to the first one

SQL and NoSQL are the two broad categories of database systems you will be asked to compare in interviews. SQL databases (PostgreSQL, MySQL, SQL Server) store data in tables with a fixed schema and use the SQL query language; NoSQL databases (MongoDB, Cassandra, Redis, DynamoDB) use document, key-value, column-family, or graph models with flexible schemas. Interviewers expect you to explain the trade-offs in data modeling, consistency guarantees, horizontal scaling, and query flexibility, and to justify a pick for a concrete scenario.

The table below summarizes the dimensions interviewers most often probe:

DimensionSQL (relational)NoSQL (non-relational)
Data modelTables, rows, fixed schemaDocuments, key-value, wide-column, or graph
SchemaRigid, enforced by the DBFlexible, often defined by the application
Query languageSQL (standardized)Varies by product (MongoDB query syntax, CQL, API calls)
JoinsFirst-class, efficientLimited or unsupported; data is often denormalized
ScalingVertical by defaultHorizontal sharding built into most products
ConsistencyStrong (ACID by default)Often eventual (BASE), though some support tunable consistency

What does an interviewer expect you to know about SQL vs NoSQL?

Beyond the definitions, you should be able to reason through a real system design. That means knowing where each model fits and where it breaks down.

  1. Pick the right model for the access pattern. If the workload is mostly ad-hoc joins over normalized data, a relational database is the natural fit. If the workload is key-based lookups on large, nested documents, a document store removes the impedance mismatch.
  2. Explain CAP in plain terms. You can have at most two of consistency, availability, and partition tolerance. In practice partition tolerance is a given on distributed systems, so the real choice is CP versus AP.
  3. Talk about scaling concretely. SQL databases scale vertically well and can scale horizontally with sharding, but the sharding logic usually lives in the application. Many NoSQL products shard and replicate automatically.
  4. Know the consistency story. PostgreSQL gives you ACID transactions across tables. MongoDB gives you tunable consistency per read and write, and Cassandra lets you pick consistency levels per query.
  5. Be ready for the follow-up "why not both?" Polyglot persistence, using a relational database for transactional records and a search engine or cache alongside it, is common in production systems.

What are common SQL vs NoSQL interview scenarios?

Interviewers like to hand you a product description and ask which database you would use. An e-commerce checkout with orders, payments, and inventory needs ACID guarantees, which points to a relational store. A social feed with write-heavy, denormalized posts and comments can lean on a wide-column or document store. A leaderboard with sub-millisecond reads is a fit for an in-memory key-value store like Redis.

Practice the questions below to check how well you can make these calls under time pressure.

Key facts

  • Tarmac has 26 Databases & SQL interview questions on this topic, 25 of them on this page, at difficulty 1–5 of 5.
  • Tarmac tracked 3,405 job postings asking for Databases & SQL in November 2026.
  • Roles asking for Databases & SQL advertise a median base salary of £70,000, across 1,264 job postings as of November 2026.
  • Tarmac last reviewed these Databases & SQL interview questions on 13 October 2026.

At a glance

Questions25 shown · 26 in the bank
Difficulty1–5 of 5
FormatsMultiple choice, Fill in the blank, True / false, Multiple answer, Ordering, Short answer

What you'll review

  1. sql vs nosql

Practice questions

Try one before you open the answer. Pick an option and press Check; it's marked on the spot.

Which statement correctly describes a key difference between traditional SQL (relational) databases and NoSQL databases?#

Options

Show answer

SQL (relational) databases enforce a fixed, predefined schema made of tables, rows, and columns, while NoSQL databases typically offer flexible or schema-less models such as documents, key-value pairs, wide columns, or graphs. The schema requirement is the key structural difference between the two families.

Why:

The core distinction is that relational SQL databases require a fixed, predefined schema built from tables, rows, and columns, while NoSQL databases typically offer flexible or schema-less models such as documents, key-value pairs, wide columns, or graphs. The statement about enforcing a fixed schema of tables, rows, and columns is the one that matches this. The statement claiming SQL stores JSON documents and NoSQL uses tables reverses the two storage models. The claim that NoSQL always requires a strict predefined schema is wrong, since NoSQL systems generally do not impose one, and the claim that SQL has no schema is also wrong. The statement that only NoSQL supports ACID is false, because relational databases are the ones traditionally known for ACID transactions and many NoSQL systems offer transactions too.

Complete the sentence:#

Show answer

Complete the sentence:

SQL databases are built on the relational model, which E.F. Codd proposed in 1970 and which stores data as mathematical relations.

Why:

SQL databases are built on the relational model, which represents data as relations (displayed as tables of rows and columns). E.F. Codd proposed this model in 1970 in his paper on relational data. The blank asking for the year is the only date in the sentence, so the answer is the single year 1970, and the first blank is the model name, relational.

Which characteristic is typically associated with NoSQL databases as a group, in contrast to traditional relational (SQL) databases?#

Options

Show answer

NoSQL databases as a group are typically characterized by flexible or schema-less data models and horizontal scaling across many commodity servers. Relational SQL databases, by contrast, enforce a predefined schema using tables and foreign keys, and usually scale vertically.

Why:

NoSQL databases as a group trade strict schema enforcement and normalized table structures for flexible data models (key-value, document, column-family, graph) and horizontal scalability across commodity hardware. The other choices describe hallmarks of relational SQL databases (normalized tables with foreign keys, a fixed enforced schema) or are false, since many NoSQL systems do not use SQL at all.

Which of the following is a key characteristic that distinguishes a relational (SQL) database from a typical document-oriented NoSQL database such as MongoDB?#

Options

Show answer

The key distinction is schema rigidity: SQL databases enforce a fixed schema where every row in a table must conform to predefined columns and data types, while document stores like MongoDB are schema-flexible, allowing documents in the same collection to have different fields. MongoDB has also supported multi-document ACID transactions since version 4.0, so flexibility in data structure — not consistency — is the defining difference.

Why:

Relational databases enforce a predefined schema (tables with fixed columns, data types, and constraints) and are built around ACID (Atomicity, Consistency, Isolation, Durability) guarantees as a core design principle. Document-oriented NoSQL databases like MongoDB are schema-flexible: documents in the same collection can have entirely different fields, making them well-suited for heterogeneous or rapidly evolving data. It is worth noting that MongoDB has supported multi-document ACID transactions since version 4.0 (and across sharded clusters since 4.2), so the primary day-to-day distinction between the two is the rigid relational schema versus the flexible document model — not consistency guarantees. The other options are factually incorrect: SQL databases use tables (not key-value pairs), NoSQL collections can hold heterogeneous documents, and SQL databases are specifically designed to express relationships via foreign keys and joins.

A NoSQL database can never support ACID transactions; ACID compliance is an exclusive feature of relational SQL databases.#

Options

Show answer

False. NoSQL databases can support ACID transactions. MongoDB has supported multi-document ACID transactions since version 4.0, and Amazon DynamoDB supports ACID transactions through its TransactWriteItems operation. ACID is therefore not exclusive to relational databases.

Why:

This statement is false. Many early NoSQL databases gave up ACID guarantees in exchange for scalability and availability, but several modern NoSQL systems support ACID transactions. MongoDB has supported multi-document ACID transactions since version 4.0, and Amazon DynamoDB supports ACID transactions through its TransactWriteItems operation. Even before those features, many NoSQL stores provided atomicity for a single document or item. Because ACID is a property that a system can provide through its transaction design, it is not limited to relational databases.

Complete the following sentences comparing SQL and NoSQL databases:#

Show answer

Complete the following sentences comparing SQL and NoSQL databases:

  1. SQL databases organize data into tables, where every row shares the same column structure.
  2. The CAP theorem says that when a network partition occurs, a distributed system must choose between Consistency and Availability.
  3. A key-value store, a document store, and a wide-column store are all examples of NoSQL database types.
Why:

SQL (relational) databases store data in tables, where every row conforms to the same column structure. The CAP theorem, conjectured by Eric Brewer in 2000 and formally proven by Gilbert and Lynch in 2002, describes what a distributed system must give up during a network partition: it cannot remain both consistent and available while the partition lasts, so it must choose between Consistency and Availability. Key-value stores (e.g., Redis), document stores (e.g., MongoDB), and wide-column stores (e.g., Cassandra) are all categories of NoSQL (non-relational) databases, unified by their departure from the strict tabular model of SQL systems.

A startup is building a content platform where each piece of content has a drastically different structure. Articles have text blocks, videos have transcripts and codec metadata, and image galleries have EXIF data. The schema evolves rapidly during development, and the team prioritizes fast iteration over strict consistency. Which statement correctly identifies a genuine advantage of a document-oriented NoSQL database for this use case?#

Options

Show answer

A document-oriented NoSQL database such as MongoDB stores each content item as a nested document, so articles, videos, and galleries can carry different fields without a fixed schema. New fields can be added during rapid development without running ALTER TABLE migrations. That schema flexibility is the genuine advantage here, not stronger ACID guarantees or the removal of indexing.

Why:

Document stores such as MongoDB keep each content item as a flexible, nested document (typically JSON/BSON) and do not enforce a fixed schema at the collection level. Articles, videos, and galleries can therefore carry different fields, and developers can add or change fields as the schema evolves without ALTER TABLE migrations, which suits rapid iteration. The distractors are wrong: document stores do not impose one fixed column layout, they do not offer stronger ACID guarantees than relational databases, and they still need indexes for efficient querying.

True or false: unlike a relational database, a document-oriented NoSQL store such as MongoDB does not require you to define a schema before inserting documents.#

Options

Show answer

True. MongoDB does not require you to define a schema before inserting documents. Collections are schema-less by default, so documents with different fields can share one collection. Optional schema validation can be added, but it is not mandatory, unlike relational tables that must declare columns and types first.

Why:

The statement is true. Relational databases enforce a schema: every table has defined columns and types, and a row that does not conform cannot be inserted. MongoDB collections are schema-less by default, so documents with different fields and structures can be inserted into the same collection without any prior schema definition. Optional schema validation exists in MongoDB but is not required.

A startup is storing user activity events (clicks, page views, purchases) for analytics. Events have variable structure (3 to 30 fields), the team expects hundreds of millions of records, and it will run ad-hoc aggregations such as revenue by region and funnel drop-off rates. Which of the following statements about relational (SQL) versus document-oriented NoSQL databases for this workload are factually accurate?#

Options

Pick every one that applies.

Show answer

Two statements hold: PostgreSQL with a JSONB payload column accepts new event fields without ALTER TABLE, and PostgreSQL can combine GROUP BY, window functions, and CTEs in one query. MongoDB does not automatically beat columnar engines like ClickHouse on aggregations, it has supported multi-document ACID transactions since 4.0, and PostgreSQL JSONB supports GIN indexing.

Why:

Two statements are accurate. A single JSONB payload column in PostgreSQL lets new event fields be written without an ALTER TABLE. PostgreSQL also lets one query combine GROUP BY, window functions, and CTEs, which suits ad-hoc analytics. The claim that MongoDB automatically outperforms ClickHouse on large aggregations is false, since columnar engines are built for scan-and-aggregate workloads. The claim that MongoDB can never do multi-document ACID transactions is false, since it has supported them since version 4.0. The claim that PostgreSQL cannot store indexed semi-structured JSON is false, because JSONB supports GIN indexing.

A team is migrating a normalized, multi-table SQL schema to a document-oriented NoSQL database (e.g., MongoDB). Arrange the following one-time migration steps in the order they must logically occur, where each step depends on the output of the step before it.#

Put these in order

Show answer

The correct sequence is: analyze SQL access patterns, design the document schema, run the transformation script to load the data, then verify the migrated documents against the SQL source. Each step needs the output of the one before it. Schema design is query-driven, so it cannot precede the access-pattern analysis. Verification cannot happen until the data has been migrated into the new store.

Why:

Each step is a prerequisite for the next. The access-pattern analysis determines which entities should be embedded or referenced, so it must come before the document schema is designed. The schema must exist before a transformation script can target its shape, and the script must run before there is migrated data to verify. Verification of the migrated documents against the SQL source comes last, because it can only compare results once the data has been loaded. The question deliberately omits cutover and dual-write steps, whose ordering varies by migration strategy, so the four-step chain has a single defensible order.

A feature needs multi-row transactions across several related entities with strong consistency, plus ad-hoc reporting that joins those entities. Which storage choice fits best, and why?#

Options

Show answer

A relational SQL database fits best, because it provides ACID transactions across rows and tables plus a join-capable engine for ad-hoc reporting. Multi-entity transactions and ad-hoc joins are exactly what the relational model is built for. Document stores shine for self-contained aggregates read and written as a unit, and key-value stores for simple lookups by key, but neither gives cross-entity transactions and rich joins for free.

Why:

Multi-entity ACID transactions and ad-hoc joins are exactly what the relational model is built for, so a SQL database is the natural fit here. Document stores shine for self-contained aggregates read/written as a unit, and key-value stores for simple lookups by key — neither gives you cross-entity transactions and rich joins for free. The right answer is workload-driven, not a blanket 'NoSQL is faster'.

A team is choosing a database for a new application. All of these requirements are known before development begins and are expected to stay stable: a well-defined schema; core queries that join five or more related tables with aggregation; strict ACID transactions spanning multiple related tables in a single operation; and a read-heavy workload with predictable, pre-defined query patterns. Which database category is the right fit for these requirements?#

Options

Show answer

A relational SQL database (such as PostgreSQL) fits this combination of requirements. It enforces a predefined schema, supports multi-table joins with aggregation through a query planner, and provides ACID transactions across related tables. Wide-column, key-value, and document stores trade some of these capabilities for write throughput, lookup speed, or schema flexibility.

Why:

The scenario asks for an enforced predefined schema, multi-table joins with aggregation, ACID transactions across related tables, and predictable read patterns. A relational SQL database provides all of these natively: a schema enforced at write time, foreign keys, a cost-based query planner for joins and aggregation, and multi-table transactions. Wide-column stores are tuned for high-throughput writes and partition-keyed access, not multi-table joins or cross-table transactions. Key-value stores offer point lookups with no native join capability. Document stores are built around flexible, self-contained documents, so joins across collections are not their native model and the flexible schema works against the stated need for a fixed one. Only the relational category matches every stated requirement.

A key distinction between SQL and NoSQL database categories is their schema enforcement strategy. SQL databases typically use a schema-on-_____ approach, where the database rejects any data that does not conform to a predefined schema before storing it. NoSQL document stores such as MongoDB typically use a schema-on-_____ approach, where data of varying structures is stored freely and the application handles interpretation and validation at access time. Fill in the two blanks.#

Show answer

A key distinction between SQL and NoSQL database categories is their schema enforcement strategy. SQL databases typically use a schema-on-write approach, where the database rejects any data that does not conform to a predefined schema before storing it. NoSQL document stores such as MongoDB typically use a schema-on-read approach, where data of varying structures is stored freely and the application handles interpretation and validation at access time. Fill in the two blanks.

Why:

The two strategies are named by when schema checking happens. In schema-on-write, data is validated against the schema when it is written, so a relational database that enforces a predefined schema on insert or update fits the blank 'write'. In schema-on-read, data is stored without enforcing a fixed structure and is interpreted when it is read, which is the approach typical of document stores such as MongoDB and fits the blank 'read'. The terms are the standard database-community names for this contrast.

A key distinction between SQL and NoSQL database categories is their schema enforcement strategy. SQL databases typically use a schema-on-_____ approach, where the database rejects any data that does not conform to a predefined schema before storing it, whereas many NoSQL document stores use a schema-on-_____ approach, where data of varying structures can be stored freely and the application handles interpretation and validation at access time. Fill in the two blanks with the single word that completes each term.#

Show answer

A key distinction between SQL and NoSQL database categories is their schema enforcement strategy. SQL databases typically use a schema-on-write approach, where the database rejects any data that does not conform to a predefined schema before storing it, whereas many NoSQL document stores use a schema-on-read approach, where data of varying structures can be stored freely and the application handles interpretation and validation at access time. Fill in the two blanks with the single word that completes each term.

Why:

In schema-on-write, the schema is enforced when data is written, so nonconforming data is rejected before it is stored; this is the SQL approach described. In schema-on-read, data is stored without enforcing a schema and structure is interpreted when it is read, which matches the document-store approach described. The blanks therefore take the words write and read.

True or false: In PostgreSQL with default (non-deferrable) foreign key constraints, an INSERT or UPDATE that sets a non-NULL foreign key value with no matching parent row is rejected by the engine when the statement executes. By contrast, MongoDB has no built-in cross-collection foreign key constraint, so referential integrity between collections must be maintained outside the database, typically by application code.#

Options

Show answer

True. In PostgreSQL with default non-deferrable foreign keys, the engine rejects a write that sets a non-NULL reference to a missing parent row when the statement runs. MongoDB has no native cross-collection foreign key, so applications must maintain that integrity themselves.

Why:

This statement is true. In PostgreSQL, a foreign key declared without DEFERRABLE (the default) is checked as each statement executes, so an INSERT or UPDATE that sets a non-NULL reference to a parent key with no matching row fails with a foreign key violation. The statement is scoped to PostgreSQL defaults because other engines differ: SQLite has enforcement off unless PRAGMA foreign_keys is on, DEFERRABLE constraints move the check to commit, and NULL values are never checked. MongoDB has no native foreign key constraint across collections, and schema validation only inspects the document being written, so the application or a mechanism such as Change Streams must maintain cross-collection integrity. The $lookup stage joins at read time and does not constrain writes.

A startup is designing a system that must:#

Options

Pick every one that applies.

Show answer

Using MongoDB instead of a relational database for this system gives schema flexibility: new fields can appear on some documents without a DDL migration. Atomicity across separate documents, such as a debit and a credit, needs a multi-document transaction, because MongoDB makes single-document writes atomic by default.

Why:

Two statements are correct. A document store lets documents in a collection carry different fields without any DDL migration, which suits weekly-evolving JSON, although application code still has to handle the varying shapes. MongoDB makes writes to a single document atomic by default, so when a debit and a credit are kept as separate documents, committing them together requires a multi-document transaction, which is supported but adds coordination overhead. The other statements are false: multi-document transactions do add overhead relative to single-document writes; MongoDB replica sets use a single primary per shard for writes rather than multi-master writes by default; and MongoDB has no declarative cross-collection foreign-key constraints.

A single-node PostgreSQL instance is sometimes labelled a CA system under the CAP theorem. In 3-5 sentences, explain why this label is misleading. Your answer should say what CAP actually constrains and what it means for a system that is not distributed.#

Show answer

CAP is a statement about distributed systems: when a network partition occurs, the system must choose between returning consistent responses and remaining available to every request. A single-node PostgreSQL instance is not distributed, so the partition scenario CAP describes does not arise for it, and CAP makes no claim about its behaviour. Calling it 'CA' implies it chose consistency and availability over partition tolerance, which is wrong because there is no partition choice to make. The label also ignores that clients can still be cut off from the node and the node can still crash, so availability is not guaranteed either.

Why:

CAP only constrains what a distributed system does when a network partition separates its nodes. A single-node PostgreSQL instance has no internal network partition, so the theorem's premise never occurs and it makes no consistency-versus-availability choice; labelling it 'CA' wrongly suggests a deliberate choice to forgo partition tolerance. Availability is also not assured, since client-to-server network failures and node crashes can make the database unreachable. The correct reading is that CAP does not apply to a non-distributed system, rather than that such a system has all three properties.

A team is migrating a heavily-used relational e-commerce database to a globally distributed NoSQL key-value store. Place the following migration steps in the order that each step's prerequisites require:#

Put these in order

Show answer

The correct order is: define the NoSQL key schema first, then take a snapshot with change capture started, then load and replay into NoSQL, then reconcile the stores, then promote NoSQL to primary, and decommission SQL last. Each step needs the output of the one before it: the schema must exist before data is loaded, the change position must be captured before replay, and parity must be confirmed before promotion.

Why:

Each adjacent pair in this order has a strict prerequisite. The key schema and access patterns must be fixed before any data is written in the NoSQL model, since they determine how records are shaped. A consistent snapshot must be taken with its change-log position recorded and change capture started from that position, so that writes made during the load can be replayed. Loading the snapshot and replaying captured changes brings the NoSQL store up to date. Reconciliation then confirms parity before promotion, and promotion to primary happens before the legacy database is decommissioned after a monitoring period. The question deliberately omits dual-write ordering, because teams legitimately choose between dual-writes and change capture for keeping stores in sync.

An e-commerce platform runs everything on PostgreSQL. The product catalog has 50M products, each with 3–300 attributes that vary by category, deep nested category hierarchies, and multi-language fields. The current schema uses the EAV (Entity-Attribute-Value) anti-pattern, which requires 3-way joins for single-product attribute lookups, and every schema change requires migrations across 200+ attribute tables. Orders and payments must remain ACID-consistent. Which approach addresses the catalog's variable-schema and join problems while keeping the rest of the platform on PostgreSQL?#

Options

Show answer

Storing the variable attributes as JSONB columns with GIN indexes in PostgreSQL is the approach that fixes the catalog's problems without a new database. It removes the EAV joins and per-attribute migrations, since new keys need no schema change, while keeping ACID transactions for orders and payments in the same system.

Why:

Storing variable attributes and multi-language values as JSONB columns in PostgreSQL removes the EAV table joins and the need for schema migrations when new attributes appear, because new keys need no DDL. GIN indexes make containment and key lookups on the JSONB data efficient, and the data stays in the same ACID database that handles orders and payments. The other options fail: MongoDB is not faster for every query and does not automatically fix all performance issues; indexing EAV tables does not remove the cost of schema changes; and MongoDB has supported multi-document ACID transactions since version 4.0, so dropping PostgreSQL is not required on that basis.

Which of the following are valid reasons to choose a NoSQL key-value store (e.g., DynamoDB or Redis) over a relational database for a specific workload?#

Options

Pick every one that applies.

Show answer

A key-value store is justified over a relational database when the workload needs single-digit millisecond point lookups at billion-item scale, horizontal write scalability with key-based access, or flexible and rapidly evolving schemas. It is not justified for workloads dominated by multi-table joins with ACID guarantees or cross-entity ad-hoc analytical aggregations—those remain relational database territory.

Why:

Key-value stores excel at single-digit millisecond point lookups at massive scale with simple access patterns, horizontal write scalability with key-based partitioning, and flexible or rapidly evolving schemas. Complex many-to-many joins with ACID guarantees and cross-entity ad-hoc analytical aggregations are core strengths of relational databases, not key-value stores—forcing these workloads into a KV model sacrifices the query expressiveness and transactional integrity that relational engines provide.

A Dynamo-style distributed key-value store uses N=3 replicas per key. The system is configured with read quorum R=2 and write quorum W=2. Explain what consistency guarantee this configuration provides and why, using the relationship between R, W, and N. Then explain what changes if R=1 and W=1 are used instead.#

Show answer

With N=3, R=2, W=2, the sum R+W=4 exceeds N=3, so any read quorum of 2 replicas must intersect any write quorum of 2 replicas in at least one replica. That replica acknowledged the latest successful write, so the coordinator can return the newest version (using version metadata such as vector clocks or timestamps to pick it). This gives a strong guarantee for a key when no write is concurrent with the read and no sloppy quorum or hinted handoff has moved writes outside the preferred replicas. It is not full linearizability: concurrent writes can produce conflicting versions that the client must reconcile, and sloppy quorums can break the overlap. With R=1 and W=1, the sum is 2, which does not exceed N=3, so the read set and write set can be disjoint. A read may contact a replica that never received the latest write and return stale data. The system then provides only eventual consistency, where replicas converge over time through hinted handoff, read repair, and anti-entropy.

Why:

The quorum intersection property is the reason. When R+W>N, any read set of size R and any write set of size W must share at least one of the N replicas, so the read includes a replica holding the latest acknowledged write and the coordinator can return the newest version. With N=3, R=2, W=2, R+W=4>3, so this holds. With R=1 and W=1, R+W=2≤3, the sets can be disjoint, so a read may hit only replicas that missed the write and return stale data, leaving only eventual consistency. The answer should also note that the overlap guarantee is not full linearizability under concurrent writes or sloppy quorums.

An inventory system must satisfy three PostgreSQL-specific requirements. Answer with exactly three items, one per line, in this form: (1) the PostgreSQL feature that makes a multi-row update spanning inventory items, warehouses and transfer orders all-or-nothing; (2) the declarative table constraint keyword that rejects any row whose on-hand stock count would drop below zero; (3) the built-in PostgreSQL column data type (not hstore) for storing per-product-category custom attributes as a binary JSON document.#

Show answer

(1) Transactions: a multi-statement update runs as one ACID-atomic unit, so it is all or nothing. (2) CHECK constraint: e.g. CHECK (on_hand >= 0) on the stock column, so the database itself rejects oversold counts. (3) JSONB: a binary JSON column holding each category's custom attributes inside the relational table.

Why:

Each requirement maps to one specific PostgreSQL feature. Requirement (1), an atomic update across several tables, is provided by transactions, which make a group of statements all-or-nothing. Requirement (2), preventing overselling, is enforced declaratively by a CHECK constraint such as CHECK (on_hand >= 0), so the database rejects any update that would make stock negative regardless of application code. Requirement (3), custom attributes per category, is handled by the JSONB column type, which stores a binary JSON document inside a relational table while still allowing indexing and querying. The answer is three named features, so a grader can match the transaction, CHECK constraint and JSONB terms directly.

In Apache Cassandra (a NoSQL wide-column store), arrange the following steps in the order they occur for a single write as it passes through the storage engine of one replica node, starting from the coordinator forwarding the mutation and ending with the memtable being flushed to disk. Background compaction is not part of this path.#

Put these in order

Show answer

In Apache Cassandra, a single write reaches a replica in this order: the coordinator forwards the mutation to the replica nodes, the replica appends it to the commit log and applies it to the memtable, and the memtable is later flushed to an immutable SSTable on disk. Compaction runs separately in the background.

Why:

This question asks for the order of one write's path on a single replica in Apache Cassandra's LSM-tree storage engine. The coordinator must first forward the mutation to the replicas that own the partition, so that forwarding step comes first. On each replica, the mutation is appended to the commit log and applied to the in-memtable; these two updates are grouped into one step because the docs do not fix an order between them. The memtable must hold the mutation before it can be flushed, so the flush of the memtable to an immutable SSTable comes last. Compaction is excluded because it is a background process that merges SSTables already on disk, not a step of one write's path.

Complete the comparison of SQL vs. NoSQL data modeling strategies. Use the form requested in each blank.#

Show answer

Complete the comparison of SQL vs. NoSQL data modeling strategies. Use the form requested in each blank.

In a relational database, the canonical design practice of splitting tables to remove redundant copies of data is called normalization (give the noun form). Relationships between tables are enforced with foreign key constraints (singular, two-word SQL keyword). Related rows are reassembled at query time using joins (plural noun for the SQL operation).

In a document database such as MongoDB, co-accessed data is often modeled by storing it directly inside the parent document, which avoids multi-document reads. This is done by embedding it (gerund form of the verb 'to embed'). However, when the same sub-document is copied into thousands of parent documents, the data is stored redundantly in many places. This redundancy is the opposite of normalization: the practice of intentionally keeping such copies is called denormalization (single word, noun form of the verb 'to denormalize'), and it makes updates costlier because every copy must be rewritten.

Why:

In a relational schema, splitting tables to remove redundant copies of data is normalization. Table relationships are enforced with foreign key constraints, and related rows are reassembled at query time using joins. In a document store, co-accessed data is modeled by embedding it inside the parent document, which avoids extra reads. Intentionally duplicating data across many parent documents is denormalization, the opposite of normalization, and its cost is that every copy must be rewritten on update. The last blank is pinned to the noun form of 'to denormalize', so only denormalization fits.

An application requires a globally distributed counter replicated across 5 geographically distant regions. Each increment must satisfy two requirements: (1) the increment is acknowledged to the client with sub-millisecond latency from any region, and (2) after acknowledgment, the increment is immediately visible to reads issued from any of the 5 regions. Which statement is correct?#

Options

Show answer

A globally distributed counter cannot meet both sub-millisecond acknowledgment and immediate cross-region read visibility at once. An increment acknowledged in under a millisecond has not yet crossed the inter-region network, which takes tens of milliseconds between continents, so remote reads cannot be guaranteed to see it.

Why:

The keyed statement is correct because the two requirements conflict physically. Immediate visibility from every region after acknowledgment is a linearizability requirement, so the write must be replicated to other regions before the client is told it succeeded. Inter-region round trips take tens of milliseconds because of the speed of light and network distance, so an acknowledgment under one millisecond cannot have waited for that propagation. The other statements fail for reasons that are each specific: a single global leader with synchronous cross-region replication must wait for remote regions before acknowledging, so it misses the latency bound; a grow-only counter CRDT acknowledges locally but only converges through anti-entropy, so it misses immediate visibility; and Cassandra's quorum overlap guarantees freshness only when the quorum replicas are reached, which spans regions and incurs the same round-trip delay.

Sources

The official documentation these questions are checked against:

Related interview questions

Job market

See databases-sql salaries and hiring demand from live job postings.

The other 1 question

This page shows 25 and marks what you pick. That's as far as a page can go. A free account opens the other 1 and keeps every answer. What you miss comes back until it's right: after a day, then at longer gaps.

Start with this topic

Free · the whole bank · 100 answers per 30 days, each marked with written feedback

Interview booked? Practise the job ad instead

What moved, monthly

One email a month when the bulletin comes out: what moved in the markets we track, and the new question topics we published. Confirm your address to join. Unsubscribe any time.