# nosql databases
// [32] real interview questions. Answers and sources live in the practice app.
practice this topic- You're storing user session state (short-lived, keyed by session ID, read on every request) plus a product catalog with faceted search. Which NoSQL family fits each, and why not one store for both?(mid)
- You're building a fraud-detection feature that traverses 'who transacted with whom, up to 4 hops away'. Would you reach for a document store or a graph database, and what breaks if you pick wrong?(senior)
- You need to store 500K time-series metrics per second, mostly appended and queried by (device, time-range), rarely updated. Document store, key-value, or wide-column — and why?(senior)
- You have a blog: posts and their comments. A post shows all its comments; comments are never queried on their own. Do you embed comments in the post document or reference them in a separate collection?(mid)
- In Mongo you embedded a user's followers array inside the user document. Now popular accounts have 2M followers and updates are slow and hitting the document size limit. What went wrong and how do you fix it?(senior)
- What is DynamoDB single-table design, and what do you gain and lose versus one table per entity type?(senior)
- Your DynamoDB table is provisioned for 10,000 WCU but writes are throttling at ~1,000/s. Metrics show one partition red-hot. What's happening and how do you fix it?(senior)
- A Cassandra table backing a job queue does frequent deletes, and reads on it have gotten catastrophically slow even though few live rows remain. What's the cause?(mid)
- You want to query a DynamoDB table by an attribute that isn't the primary key (e.g. orders by status). You reach for a Global Secondary Index. What are the real costs to weigh?(senior)
- In Cassandra you added a secondary index on a high-cardinality column (like email) to query by it. Why is this a trap, and what's the idiomatic alternative?(senior)
- In Cassandra, explain how write consistency level and replication factor combine to give you strong consistency, and what you trade for it.(senior)
- MongoDB exposes write concern (w, j) and read concern. Frame these as decisions: when do you loosen them and when must you tighten?(mid)
- You paginate a list with .skip(offset).limit(20). At page 5000 the endpoint is slow and users see duplicate/missing rows. Why, and what replaces offset pagination?(mid)
- DynamoDB pagination uses LastEvaluatedKey rather than an offset. How does cursor-based paging work here and why is there no 'page N'?(senior)
- You want session tokens, verification codes, and cart data to auto-expire. Compare TTL in Redis, DynamoDB, and MongoDB as design choices.(mid)
- A teammate wants to move a JSON-heavy feature from Postgres to MongoDB 'because it's document data'. When does Postgres JSONB actually beat Mongo, and what's the honest case for each?(senior)
- You must add a required 'country' field to 200M existing Mongo documents that don't have it, with zero downtime. How do you run this migration?(senior)
- You run DynamoDB global tables across us-east-1 and eu-west-1. The same shopping-cart item gets edited in both regions within the same second. How is the conflict resolved and why is that dangerous?(senior)
- Explain how a MongoDB sharded cluster distributes data and why the shard key is the most consequential decision you make.(mid)
- Redis is single-threaded for command execution yet handles 100K+ ops/sec. How is that possible, and what does it imply for the commands you run?(mid)
- You cache DB reads in Redis. Under a traffic spike a popular key expires and thousands of requests simultaneously miss and hammer the database. What is this and how do you prevent it?(senior)
- Your Mongo aggregation over 50M documents runs for minutes and spikes memory. How do you diagnose and fix a slow pipeline?(senior)
- 'NoSQL means no ACID' is folklore. What transaction guarantees do MongoDB and DynamoDB actually offer today, and what's the catch?(senior)
- You need a leaderboard: top-100 players by score, plus a given player's rank, updated live for millions of players. Which NoSQL primitive nails this and why?(senior)
- DynamoDB lets you read with eventual or strong consistency. Frame the choice: when do you pay for a strongly consistent read and when is eventual fine?(mid)
- Two concurrent clients read a counter and both write value+1, losing an update. How do NoSQL stores let you make this write safe without a full transaction?(senior)
- You're picking between DynamoDB on-demand and provisioned capacity for a new service with unknown, spiky traffic. How do you decide, and how does this shape your table design?(senior)
- You need to react to every change in a NoSQL table — update a search index, send an email, keep a cache warm. How do NoSQL change-data-capture features let you do this without polling?(mid)
- A stakeholder says 'NoSQL scales infinitely, SQL doesn't — always pick NoSQL for a new service.' Push back with the real tradeoff.(senior)
- You're modeling a chat app in DynamoDB: users, conversations, and messages, with 'load a conversation's latest 50 messages' as the hot query. Sketch the single-table keys.(senior)
- An Instagram/WhatsApp Story vanishes exactly 24 hours after you post it — nobody manually deletes it. How do you model auto-expiring content so it disappears on time without a cron job scanning everything?(mid)
- The little red badge on your messaging app shows '7 unread' and updates the instant a new message lands or you open the chat. How do you keep a per-user unread counter accurate and fast for millions of users?(mid)