Skip to content
Tech Interview Prep
Technical interview guide

NoSQL, Graph & Key-Value Data Stores

When a relational database isn't the right fit: document, key-value, graph, and vector stores, and how to choose between them.

Read
23 min
Practice MCQs
25
Interview Q&A
25
Edition
v3
Editorial status
Reviewed

Scope: SQL principles with PostgreSQL 18 examples; vendor-specific behavior must be verified.

Curated: · Written: · Reviewed:

25 questions

MCQ-15A team is moving one workload onto a plain key-value store. The store exposes a single access path, get or put by primary key, and the team has no budget for secondary indexes or extra write throughput. Which workload fits as-is?
MCQ-5A team is choosing a store for a new service and lists reasons for picking a document store over a relational one. Which of these reasons is not actually a benefit of the document model?
MCQ-1A team needs a session store that answers 50k lookups/s by session ID with a p99 under 1 ms, and picks a pure key-value store over a relational table carrying a secondary index on user_id. What does that choice cost them?
MCQ-21A team stores each user's activity log as an array embedded in that user's MongoDB document. Each log entry is about 1.2 KB, and a busy user generates roughly 150 entries a day. The team plans to keep 90 days of history in the embedded array before archiving. What does the 16 MB per-document limit mean for that plan?
MCQ-6A game backend keeps each player's best score in the Redis sorted set `scores`. A session ends with these commands run in order: ``` ZADD scores 4200 alice 3900 bob 5100 carol 4000 erin 2800 dave ZINCRBY scores 1500 dave ZREVRANK scores dave ``` What does the final command return?
MCQ-11A Postgres 16 table `events` holds 400M rows with a `payload jsonb` column. Queries of the form `SELECT ... WHERE payload @> '{"type":"click"}'` take about 90 seconds; `EXPLAIN` shows a sequential scan, and the predicate matches roughly 2% of rows. The team ran `CREATE INDEX events_payload_idx ON events USING btree (payload);` and the plan is unchanged. What explains why the index is not used?
MCQ-3A table is defined as `CREATE TABLE events (tenant_id text, bucket int, event_time timestamp, payload text, PRIMARY KEY ((tenant_id, bucket), event_time))`. A service runs `SELECT * FROM events WHERE tenant_id = 'acme' AND event_time > '2024-05-01'` and Cassandra rejects it with 'Cannot execute this query as it might involve data filtering'. Adding `AND bucket = 7` makes the same query succeed. What does the added predicate supply?
MCQ-8A fleet of 5,000 sensors writes one reading per second. The team is moving the readings out of a relational table (one row per reading, B-tree index on `(sensor_id, ts)`) into a wide-column store, where each stored row is about 200 bytes including overhead. The only read pattern is "every reading for sensor X over the last 90 days", and the team's SLO is that this query touches at most 100 partitions while no partition exceeds the 100 MB guideline. Which partition key meets both?
MCQ-2A MongoDB 7.0 orders collection stores each order as a single document. Line items average 250 bytes; typical orders have 20, but a bulk-order path has produced orders with 90,000 line items and keeps producing them. The order detail page reads the order and all its line items together. Which design should the team adopt?
MCQ-14An order-detail page on MongoDB 7.0 loads one order document, then issues one find() per line item to read each item's name and price from an items collection, 40 finds for a typical order, plus one find() for the customer. The profiler shows 42 round trips per page view and p99 latency of 210 ms against a 50 ms budget. Which failure mode does this model exhibit?
MCQ-4A social graph store holds 40M users and 1B friendship edges. A 3-hop traversal from a user with 150 friends, on a graph where the average user has 50 friends, visits about 383,000 nodes and returns in 20 ms. The team then imports another 40M users and 1B edges, keeping the average degree at 50. The same 3-hop query now visits about:
MCQ-12An orders service on MongoDB keeps orders and their line items in two collections and updates both inside a multi-document transaction. The transaction is the slowest step in the write path, and the team wants the order and its items to change together without one. Line items are never read without their order, and the largest order has a few hundred items. Which change meets the requirement?
MCQ-24A 3-node MongoDB 6.0 replica set keeps live orders in a `pending` collection and finished ones in `archived`. A nightly job reads 40,000 pending orders (about 2 KB each), inserts them into `archived`, and deletes them from `pending`, all inside one multi-document transaction with default settings. The transaction fails with a write error about 12 seconds in. What is the cause?
MCQ-16A 200-node Cassandra cluster holds 2 billion events in a table keyed by user. A new dashboard needs the 100 most recent events for a tenant in the last 24 hours. The query is `SELECT * FROM events WHERE tenant_id = ? AND event_time > ? ORDER BY event_time DESC LIMIT 100`. The team needs p99 under 200 ms and cannot change the existing table's primary key. Which table design and migration plan meets the requirement?
MCQ-18A team is adding an events table to a 12-node Cassandra cluster. Their first key, `PRIMARY KEY ((event_date), event_id)`, puts every write for the current day in one partition; the nodes holding it run at 90% CPU while the rest of the cluster idles near 10%. They are choosing a replacement partition key. Which property of the new key fixes this?
MCQ-7A store shards by consistent hash on `tenant_id` across 8 nodes, and each node sustains 12,000 writes/s before it starts queueing. The cluster takes 30,000 writes/s, and one tenant, `acme`, accounts for 45% of that (13,500 writes/s) all of which hashes to node 3. Node 3's p99 write latency is 900 ms, while the other seven nodes sit at about 20% of their write ceiling. The team doubles the cluster to 16 nodes, and acme's p99 stays at 900 ms. What explains that?
MCQ-19A trading service keeps its authoritative order log in Redis 7.2 with `appendonly yes`, `appendfsync everysec`, and one asynchronous replica in a second zone. The primary sustains 5,000 order writes/s. The primary's host fails and the replica is promoted; 2,000 confirmed orders are missing. At the moment of failure the replica's applied write stream was 0.4 s behind the primary's. What does this point to?
MCQ-9An orders service has run on MongoDB for 14 months with no schema validation. Release 11 writes documents shaped `{_id, total}`. Release 12 adds a `currency` field, and its read path calls `order.currency.toUpperCase()`. The deploy is rolling: over a six-minute overlap, release 11 pods write 4,137 orders and release 12 pods write 862. The collection held 2,104,000 orders when the deploy began. After the deploy finishes, which documents make the release 12 reader throw?
MCQ-20A payments team routes every write through a shared service layer that validates each field before insert. A nightly backfill job writes directly to the tables, bypassing the service. Three weeks later the ledger under-reports: the backfill inserted rows with a NULL account_id, and the reconciliation join silently dropped them. Which guarantee was missing?
MCQ-13A team moves product search off Postgres to Elasticsearch while Postgres stays the system of record for prices. The write path commits to Postgres, then calls Elasticsearch in the same request handler; if the Elasticsearch call fails, the handler logs the error and returns success. During a 40-minute Elasticsearch outage, 6,200 price updates commit to Postgres and 6,200 Elasticsearch calls fail. Search still returns the old prices. Which statement best describes what the team is now facing?
MCQ-23A team moved per-carrier shipping webhook payloads out of its PostgreSQL orders table into a document store. Payload writes and order-row writes now hit two systems, and the team keeps finding payloads whose matching order row rolled back. Which reason justifies moving the payloads back into a jsonb column on the orders table?
MCQ-10A payments team's fraud review runs one query per case: walk outward from a flagged account until it reaches a known-bad account or the analyst's hop budget runs out (2–6 hops, set per case). On Postgres the recursive CTE over 40M edges takes 2.4 s at p99 against a 300 ms budget. Everything else the service does (account writes, device records, merchant links) is single-row updates and fixed two- or three-table joins that meet their budgets, and the schema has not changed in two years. Which fact about this workload justifies moving it to a graph database?
MCQ-17A payments team runs PostgreSQL 16 on one 16 vCPU / 64 GB RAM node with a 2 TB NVMe volume. The `ledger` table holds 380M rows (210 GB on disk); the hot composite index on (account_id, posted_at) is 14 GB and stays cached, and the balance query runs at 9 ms p99. The roadmap projects 2.5x row growth over 24 months, and the write path needs serializable transactions spanning two accounts. A proposal argues for migrating to a sharded document store 'to scale writes.' Which call do these numbers support?
MCQ-22A payments service keeps 800M rows in one Postgres table (about 18 months of data, ~200 bytes/row). Two workloads hit it. Point lookups (`WHERE account_id = ? AND created_at > now() - interval '30 days' ORDER BY created_at DESC LIMIT 20`, 95% of queries) run at 12 ms p99 on the existing `(account_id, created_at)` B-tree. The other 5% are ad-hoc reports like `SELECT merchant_category, sum(amount) FROM payments WHERE created_at BETWEEN ? AND ? GROUP BY merchant_category`, which scan 3–6 months (130M–270M rows) and take 40–90 s on a read replica, saturating its I/O. The reports must get faster and the point-lookup latency must not regress. What should the team do?
MCQ-25A team runs a 500 GB Postgres database for a seat-booking service: 900 writes/s, 8k reads/s, p99 read 20 ms against a 50 ms SLO. Analysts query a read replica, so ad-hoc reporting is not a factor. The team is deciding whether to move the primary to a document store. Which fact about the write path most directly argues for keeping Postgres?