Amazon DynamoDB Tutorial 0/30 lessons ~6 min read Lesson 30

    DynamoDB Interview Preparation

    This lesson brings the whole course together as interview practice: core concepts, data modeling, indexes, streams, transactions, global tables, and operations.

    Course progress0%
    Focus
    6 guided sections
    Practice signal
    Examples included
    Career prep
    Interview Q&A included

    Introduction

    This lesson brings the whole course together as interview practice: core concepts, data modeling, indexes, streams, transactions, global tables, and operations. Answer each question out loud before expanding it, then work through the design exercise at the end.

    Purpose of this lesson

    You will review the questions interviewers ask most often about DynamoDB and practise a full single-table design under time pressure.

    Understanding the topic

    What interviewers look for:

    • You start from access patterns, not entities.
    • You can explain partition keys, hot partitions, and capacity math.
    • You know when to use GSIs vs LSIs, Query vs Scan, transactions vs conditional writes.
    • You design failure handling for streams and retries.
    • You know when DynamoDB is the wrong choice.

    Advanced interview questions

    Interview Prep

    Practice concise answers, then expand each card for the explanation.

    10 questions
    1BeginnerQuestionExplain partition keys and sort keys.+

    Answer

    The partition key is hashed to choose the physical partition; items with the same partition key form an item collection. The optional sort key orders items within the collection and supports range conditions. Together they form the primary key, which must be unique.
    2BeginnerQuestionHow many WCUs does writing a 2.5 KB item use?+

    Answer

    Three. Writes are billed per 1 KB rounded up. A transactional write of the same item uses six.
    3BeginnerQuestionWhy are Scans discouraged?+

    Answer

    They read every item in the table or index and charge for all of it, page at 1 MB, and compete with production traffic. Design keys and indexes so application paths use Query or GetItem.
    4IntermediateQuestionGSI vs LSI?+

    Answer

    GSI: any keys, add anytime, eventually consistent, separate capacity. LSI: same partition key, different sort key, create-time only, strong reads, shared capacity, 10 GB item-collection limit.
    5IntermediateQuestionHow do you model a many-to-many relationship?+

    Answer

    With an adjacency list: edge items keyed by both nodes, and an inverted GSI (SK as partition key, PK as sort key) to traverse in the other direction.
    6IntermediateQuestionHow do you guarantee unique usernames?+

    Answer

    Write a USERNAME#value claim item with attribute_not_exists(PK) in the same transaction as the user item.
    7IntermediateQuestionWhat happens when a Lambda stream consumer keeps failing on one record?+

    Answer

    Without limits it retries that batch until the records expire after 24 hours, blocking the shard. Use ReportBatchItemFailures, bisecting, retry limits, and an on-failure destination.
    8AdvancedQuestionHow do global tables handle write conflicts?+

    Answer

    In the default mode, last writer wins across Regions. Avoid conflicts by routing writes for each item to a single home Region.
    9AdvancedQuestionA table is throttling but consumed capacity is low. What is happening?+

    Answer

    Most likely a hot partition key exceeding per-partition limits, or a throttled GSI back-pressuring writes. Check Contributor Insights and GSI throttle metrics, then fix key distribution or shard the hot key.
    10IntermediateQuestionWhen would you not use DynamoDB?+

    Answer

    When access patterns are unknown or change constantly, when you need ad-hoc joins and aggregations, complex reporting, or relational constraints across many entities. A relational database or a warehouse is a better fit.

    Hands-on exercise

    Design exercise (30 minutes): design the table for a ride-sharing app with these access patterns: get rider profile; list a rider's trips newest first; get a trip with its location updates; list available drivers in a city zone; ensure a driver is assigned to only one active trip; expire location updates after 30 days. Write the key layout, indexes, transactions, and TTL settings, then compare with the solution notes below.

    • Rider: PK=RIDER#id, SK=PROFILE; trips under the rider: SK=TRIP#<ISO time>#tripId (Query, descending).
    • Trip: PK=TRIP#id with SK=HEADER and SK=LOC#<ISO time> items; TTL expiresAt on location items.
    • Available drivers: sparse GSI on availableZone = CITY#zone (set only while available), sharded if zones are hot.
    • One active trip per driver: transaction that conditionally sets activeTripId on the driver item (attribute_not_exists(activeTripId)) and creates the trip.

    Summary

    Interview success with DynamoDB comes from access-pattern-first modeling, clear capacity math, the right index and write primitives, robust stream handling, and knowing DynamoDB's limits.

    Ready to mark this lesson complete?Track your journey across the entire course.