DynamoDB interview questions and answers, from keys to single-table design

DynamoDB interview questions test whether you design from access patterns: pick a partition key that spreads load, a sort key that answers range queries, and secondary indexes for the queries the base table cannot serve. Interviewers then check GSIs versus LSIs, single-table design, on-demand versus provisioned capacity, hot partitions, and conditional writes for idempotency and optimistic locking. Strong DynamoDB answers list the queries first and the table second.

By Published 7 min read

Where DynamoDB interview questions come from

DynamoDB shows up in AWS-heavy backend interviews, serverless roles built around Lambda and API Gateway, and system design rounds where a candidate needs a key-value store with predictable latency at any size. The common format is a modeling exercise: here is an e-commerce or SaaS app, list its access patterns, design the keys and indexes. Experienced candidates also get throttling incidents, cost-aware capacity choices and how to get data out for analytics.

  1. ScreenKeys, Query versus Scan, item size limit, consistency options, the difference between GSI and LSI.
  2. Modeling exerciseTurn five to eight access patterns into a table design, often single-table, and write the key expressions for each.
  3. Scenario roundThrottling on one key, a duplicate order from a retry, a reporting request that would need a scan, or a multi-region requirement.

Fundamentals: keys, items and reads

DynamoDB basics
QuestionWhat it testsWhat a strong answer shows
What is the difference between a partition key and a sort key?Primary keyThe partition key is hashed to choose where an item lives. A sort key, if present, orders items that share a partition key, and the pair must be unique. Items with the same partition key form an item collection.
What is the maximum item size?Limits400 KB, attribute names included. Large blobs go to S3 with a pointer in the item.
What is the difference between Query and Scan?Access costQuery reads one partition key's items, optionally narrowed by a sort key condition. Scan reads the whole table or index and filters afterwards. Scans are for exports and backfills, not request paths.
Does a FilterExpression reduce what you pay for?Read capacityNo. Filters run after items are read, so capacity is consumed for everything read. Push the condition into the key design instead.
How does pagination work?PagingA Query or Scan returns up to 1 MB of data per call and a LastEvaluatedKey; pass it as ExclusiveStartKey to continue. There is no offset.
Eventually consistent or strongly consistent reads?ConsistencyReads are eventually consistent by default and cost half as much capacity. Strongly consistent reads return the latest committed write but are not available on global secondary indexes.
What sort key conditions are allowed in a Query?Key expressionsEquality, less than and greater than, BETWEEN and begins_with. Sort keys built from prefixes and dates make those conditions useful.
How do you get items in descending order?OrderingSet ScanIndexForward to false, for example to read a customer's newest orders first.
DynamoDB basics. Scroll sideways on a small screen.

Secondary indexes: GSIs and LSIs

Index questions
QuestionWhat it testsWhat a strong answer shows
What is the difference between a GSI and an LSI?Index typesA GSI has its own partition and sort key, can be added at any time and is eventually consistent. An LSI keeps the table's partition key with a different sort key, must be created with the table, and allows strongly consistent reads.
What does projection mean on an index?Storage and costWhich attributes are copied into the index: keys only, selected attributes or all. Projecting less saves storage and write cost; projecting too little forces extra reads of the base table.
What is a sparse index?Selective indexingA GSI only contains items that have its key attributes. Set the attribute only on items you want indexed, such as open tickets, and the index stays small.
What is the catch with tables that have LSIs?Item collectionsThe items sharing one partition key, across the table and its LSIs, are capped in total size (10 GB), which can surprise a design with very large tenants.
Can a slow GSI hurt writes to the base table?Back-pressureYes. With provisioned capacity, if a GSI lacks write capacity, writes to the base table that touch it can be throttled. Give indexes enough capacity or use on-demand.
How many indexes can a table have?QuotasLSIs are limited to a handful per table, and GSIs have a default quota that is larger. Check current service quotas instead of quoting a number in production planning.
Index questions. Scroll sideways on a small screen.

Single-table design

Interviewers who use DynamoDB daily often ask you to put several entity types in one table. The idea: give keys generic names such as PK and SK, prefix values with the entity type, and arrange them so a single Query returns everything one screen needs. The table below shows a small store with customers, orders and order items.

Fictional single-table layout for customers and orders
PKSKGSI1PKGSI1SKServes
CUSTOMER#c42PROFILEEMAIL#ana@example.comCUSTOMER#c42Get customer by id; find customer by email through GSI1
CUSTOMER#c42ORDER#2026-11-30#o981ORDER#o981ORDER#o981List a customer's orders newest first (begins_with ORDER#)
ORDER#o981ITEM#1Get all line items of one order with one Query
ORDER#o981ITEM#2Same item collection as the line above
CUSTOMER#c42ORDER#2026-10-02#o640ORDER#o640ORDER#o640Look up an order by id through GSI1 without knowing the customer
Fictional single-table layout for customers and orders. Scroll sideways on a small screen.
  • Why put different entities in one table? Items that are read together live in the same partition, so one Query replaces several round trips or a join. It also keeps indexes and capacity in one place.
  • What are the costs of single-table design? It is hard to read without documentation, every new access pattern needs thought, and analytics teams need an export to a warehouse. Some teams prefer a table per entity when access patterns are simple.
  • What is index overloading? Using one GSI with generic key names for several entity types, so the same index answers different queries depending on the prefix.
  • How do you model many-to-many relations? The adjacency list pattern: an item per relationship with both ids, plus an inverted GSI that swaps PK and SK, so you can query from either side.
  • How do you handle a new access pattern after launch? Add a GSI and backfill the attributes it needs with a script, or write a second item type. Plan the backfill as a migration with idempotent writes.

Capacity, throttling and hot partitions

import math


def read_units(item_kb: float, strongly_consistent: bool = False, transactional: bool = False) -> float:
    units = math.ceil(item_kb / 4)          # one RCU = one 4 KB strongly consistent read
    if transactional:
        return units * 2
    return units if strongly_consistent else units / 2


def write_units(item_kb: float, transactional: bool = False) -> int:
    units = math.ceil(item_kb / 1)          # one WCU = one 1 KB write
    return units * 2 if transactional else units


print(read_units(6))                         # 1.0  (two 4 KB chunks, halved)
print(read_units(6, strongly_consistent=True))  # 2
print(write_units(2.5))                      # 3
print(write_units(2.5, transactional=True))  # 6
Capacity unit arithmetic used in sizing questions. Run with python3; output in the comments.
  • On-demand or provisioned capacity? On-demand bills per request and absorbs unpredictable traffic without planning. Provisioned with auto scaling suits steady, predictable load and is usually cheaper per request at that point. Many teams start on demand and switch once traffic is known.
  • What is a hot partition? One partition key getting far more traffic than others. Each physical partition has a throughput ceiling, so it throttles even when the table as a whole has spare capacity.
  • How do you fix a hot key? Write sharding: add a suffix from a small range to the partition key and fan reads out across the suffixes, or cache hot reads with DAX or another cache. Adaptive capacity helps with uneven load but cannot fix a single key that exceeds a partition's limit.
  • What does a ProvisionedThroughputExceededException mean for the client? The request was throttled. The SDKs retry with exponential backoff; the fix is capacity, key design or caching, not more retries.
  • How do you run a big Scan without hurting production? A parallel scan with segments, limited page size and rate limiting, against a time when traffic is low, or better, export the table to S3 and process it there.

Writes: conditions, transactions, streams and TTL

import boto3

ddb = boto3.client("dynamodb")

# Create the order only if this id has never been written: retries become harmless.
ddb.put_item(
    TableName="store",
    Item={
        "PK": {"S": "ORDER#o981"},
        "SK": {"S": "META"},
        "status": {"S": "PLACED"},
        "version": {"N": "1"},
    },
    ConditionExpression="attribute_not_exists(PK)",
)

# Change status only if nobody else updated the item since we read version 1.
ddb.update_item(
    TableName="store",
    Key={"PK": {"S": "ORDER#o981"}, "SK": {"S": "META"}},
    UpdateExpression="SET #s = :new, #v = #v + :one",
    ConditionExpression="#v = :expected",
    ExpressionAttributeNames={"#s": "status", "#v": "version"},
    ExpressionAttributeValues={
        ":new": {"S": "SHIPPED"},
        ":one": {"N": "1"},
        ":expected": {"N": "1"},
    },
)
# A failed condition raises ConditionalCheckFailedException: re-read and decide.
boto3 calls for an idempotent create and an optimistic-locking update. Parsed with python3 only; boto3 is not installed here and no table was called.
Write-side questions for experienced DynamoDB developers
QuestionWhat it testsWhat a strong answer shows
Why are #s and #v used instead of the attribute names?Reserved wordsstatus is a reserved word in expressions, so it must go through ExpressionAttributeNames. Aliasing every attribute name, as with #v, is a safe habit that also handles names with dots or dashes.
When do you need a transaction?AtomicityWhen several items must change together, such as reserving stock and creating an order. TransactWriteItems is all-or-nothing, costs double capacity, and has an item-count limit; keep transactions small and rare.
How do you enforce a unique email across users?UniquenessA second item keyed by the email, written in the same transaction as the user with attribute_not_exists on both. A GSI cannot enforce uniqueness.
What are DynamoDB Streams used for?Change data captureAn ordered per-item log of changes, kept for about a day, consumed by Lambda or the Kinesis adapter to update search indexes, send events or maintain aggregates.
How does TTL deletion work?ExpiryYou store an epoch-seconds timestamp in a TTL attribute; a background process deletes expired items, typically within days rather than at the exact second, so queries should also filter on the timestamp. The deletes appear in the stream.
How do batch operations differ from transactions?BatchingBatchWriteItem and BatchGetItem group independent requests to save round trips, but each item succeeds or fails on its own, and unprocessed items must be retried.
What do global tables give you?Multi-regionReplicas in several regions that all accept writes. Conflicting concurrent writes resolve by last writer wins by default, so design so the same item is not edited in two regions at once.
When would you put DAX in front of a table?CachingRead-heavy, latency-sensitive workloads with repeated reads of the same items. It does not help write-heavy tables or strongly consistent reads.
Write-side questions for experienced DynamoDB developers. Scroll sideways on a small screen.

Fictional example

Answering "Customers were charged twice when the client retried a timed-out checkout"
Interviewer
The checkout Lambda writes an order with put_item and then calls the payment provider. On a timeout, the mobile app retries the whole request.
Candidate
The retry creates a second order because put_item with a new generated id always succeeds. I would have the client send an idempotency key with the checkout, use it as the order id, and write with ConditionExpression attribute_not_exists(PK). The first request creates the item; a retry gets ConditionalCheckFailedException, and the handler reads the existing order and returns its status instead of charging again. I would also pass the same key to the payment provider, since most support idempotency keys, and record the payment result on the order with a conditional update on status, so a late duplicate response cannot move it backwards. A stream consumer can alert on any order stuck in PENDING for more than a few minutes.

Ten-day DynamoDB practice plan

  • Days 1 and 2: take three apps you know and list every access pattern before drawing any keys.
  • Days 3 and 4: design single-table layouts for them, with a table of PK, SK and index keys like the one above.
  • Days 5 and 6: use DynamoDB Local or a free-tier test table to write the queries, conditional puts and a small transaction.
  • Day 7: practice capacity arithmetic and explain when on-demand or provisioned capacity fits a traffic pattern.
  • Days 8 and 9: rehearse the hot partition, duplicate write and analytics export scenarios out loud.
  • Day 10: time a full modeling exercise and review what you skipped.

If the role is cloud-wide, pair this with AWS interview questions. For the open-source wide-column store that shares partition-first modeling, see Cassandra interview questions; for search over DynamoDB data fed by streams, see Elasticsearch interview questions. When analysts want the data, it usually lands in a warehouse such as the one in BigQuery interview questions. The design trade-off itself is covered in SQL vs NoSQL.

DynamoDB modeling is easier to review on paper than in memory. Natively, an AI interview assistant for Mac and Windows, transcribes a mock session on your computer, so you can see whether you listed access patterns before naming keys. In practice it can read a table design or an error message from a screenshot and suggest next steps, and with Pro or the free trial it uses the résumé and job description you add. Transcripts and notes remain available afterwards.

Questions people ask

What DynamoDB questions are asked in interviews?

Expect partition and sort keys, Query versus Scan, GSIs versus LSIs, single-table design from access patterns, on-demand versus provisioned capacity, hot partitions, conditional writes, transactions, streams, TTL and global tables.

What is the difference between a GSI and an LSI in DynamoDB?

A GSI has its own partition and sort key, can be added at any time and supports only eventually consistent reads. An LSI keeps the table's partition key with another sort key, must be defined when the table is created and supports strongly consistent reads.

What is single-table design in DynamoDB?

Storing several entity types in one table with generic key names and type prefixes, arranged so that one Query returns related items together, such as a customer and their recent orders.

How do you prevent duplicate writes in DynamoDB?

Use a client-supplied id as the key and write with a ConditionExpression such as attribute_not_exists(PK). A retry then fails the condition instead of creating a second item.

Where to go next

Practice with the same assistant you would use on a call: it listens, transcribes and suggests answers from your own resume and the job description.

Facts on this page were last checked on . Product details come from the Natively app itself; if something here is out of date, tell us at hello@heynatively.com.

Keep reading

Put it on your own machine.

A live-conversation assistant that runs locally. Your conversations stay on your machine.

macOS 12+ · Windows 10/11

© 2026 Natively AI Private Limited

Source-available under the Natively Personal Use Source License v1.0 · IP geolocation by DB-IP