Scrivio Interview library

NoSQL fundamentals

26 questions in 9 subtopics.

Document stores

ConceptFoundations6 min read
What is a document store such as MongoDB, and when would you store an order with its line items as one document instead of two relational tables? What are the limits of embedding?
DebuggingIntermediate7 min read
A MongoDB collection of user activity documents, each with an embedded events array that grows with every click, has become slow to update and some writes fail. Explain what is happening and how you would remodel it.
DesignAdvanced7 min read
A team wants to move a product catalog from PostgreSQL to a document database because 'the schema changes too often'. As an architect, how do you evaluate the request?

Key-value stores

ConceptFoundations6 min read
What operations does a key-value store like Redis or DynamoDB (used as key-value) give you, and why are they fast? Give two good and two bad use cases.
ScenarioIntermediate7 min read
A Redis instance used as a cache for a Java service shows a single key read 200,000 times per second during a sale, one shard at 100 percent CPU and others idle. What is the problem and how do you fix it?

Wide-column stores

ConceptFoundations6 min read
Explain the data model of a wide-column store such as Apache Cassandra: partition key, clustering columns, and why queries must usually include the partition key.
DebuggingIntermediate7 min read
A Cassandra table messages_by_chat with PRIMARY KEY (chat_id, sent_at) works well for small chats, but reads for a few very large group chats time out and nodes show long GC pauses. Explain and redesign.
DesignAdvanced7 min read
Your company runs a large Cassandra cluster for user timelines, and the team proposes moving to a managed wide-column or key-value service. What do you evaluate?

Graph databases

ConceptFoundations6 min read
When is a graph database such as Neo4j a better fit than a relational database? Write a Cypher query that finds friends of friends of user 42 who are not already friends.
ScenarioIntermediate7 min read
A fraud team wants to detect rings of accounts that share devices, phone numbers or addresses within 3 hops, in near real time, and the current PostgreSQL recursive query takes minutes. How would you approach it?
LeadershipPrincipal6 min read
Your company has run a graph database for five years for recommendations, but only one team understands it, and its licence cost has grown. What options do you put in front of leadership?

CAP and PACELC

ConceptFoundations6 min read
Explain the CAP theorem correctly, including the common misunderstanding, and what PACELC adds.
ScenarioIntermediate7 min read
Your inventory service runs in two regions with a multi-region database. During a network split between regions, both sides keep accepting orders for the last 5 units of an item. Which trade-off was made, and how would you change the design?
LeadershipPrincipal7 min read
Executives ask for 'five nines availability and perfectly consistent data in every region'. How do you explain the trade-offs at company level and turn them into decisions?

Consistency models and quorums

ConceptFoundations7 min read
In a Dynamo-style store with replication factor N=3, explain read and write quorums R and W. Why does R + W > N give you reads that see the latest acknowledged write, and what can still go wrong?
DebuggingIntermediate7 min read
Users sometimes update their profile and then see the old value on refresh. The service writes to a primary and reads from replicas. Name the consistency guarantee that is missing and three ways to provide it.
DesignAdvanced7 min read
Define a consistency standard for your platform so that teams describe and choose consistency deliberately instead of by database default. What levels would you name and how would you enforce them?

Modeling for access patterns

DesignFoundations7 min read
For a DynamoDB-style single table, model these access patterns for an e-commerce app: get a customer by id, list a customer's orders newest first, and get an order with its items. Show partition and sort keys.
ScenarioIntermediate7 min read
Six months after launch, the product team asks for a new query on a Cassandra-based system: all orders by product across customers in the last week. The data model has orders_by_customer only. What are your options?
LeadershipPrincipal6 min read
Over ten years your organisation adopted MongoDB, Cassandra, DynamoDB, Redis and Neo4j, each chosen by a team, and now struggles with skills, cost and data integration. What would you do?

Time-series databases

ConceptFoundations8 min read
What makes a time-series database (for example TimescaleDB, InfluxDB or a PostgreSQL time-partitioned table) different from storing metrics in a normal table? Name three features you would expect.
ScenarioIntermediate7 min read
A metrics system stores per-request latency with labels for user id, endpoint and region; storage and query time have grown ten times in a month. What is the likely cause and what do you change?
DesignAdvanced7 min read
Your company stores IoT sensor readings from 2 million devices, one reading per device every 10 seconds, kept for 2 years, with dashboards for the last day and reports over years. Design the storage.

Vector databases

ConceptFoundations7 min read
What does a vector database store, and how does an approximate nearest neighbour index like HNSW answer a similarity query? When can PostgreSQL with pgvector be enough?
DebuggingIntermediate7 min read
A retrieval feature using pgvector returns poor results after adding a metadata filter WHERE tenant_id = ? to an HNSW query with LIMIT 10. Often fewer than 10 rows come back. Explain and fix.
LeadershipPrincipal6 min read
Vendors pitch dedicated vector databases for every AI project. How would you decide the company's long-term approach to vector search?