designing-dynamodb-tables

Design DynamoDB single-table schemas with keys and GSIs for access patterns.

1|Updated Nov 3, 2025
One-click install
npx skills add https://github.com/swapkats/robin --skill designing-dynamodb-tables
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: designing-dynamodb-tables
Source: https://github.com/swapkats/robin/tree/main/skills/designing-dynamodb-tables
Command: npx skills add https://github.com/swapkats/robin --skill designing-dynamodb-tables

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

DynamoDB schema design is notoriously complex, often leading to inefficient queries, high costs, and scalability bottlenecks if not done correctly. This skill eliminates the guesswork, automating the application of battle-tested best practices for single-table design.

Core Features & Use Cases

  • Optimized Single-Table Schemas: Automatically designs DynamoDB single-table schemas, ensuring optimal performance, cost-efficiency, and scalability by co-locating related data.
  • Access Pattern-Driven Design: Crafts primary and global secondary indexes (GSIs) specifically to fulfill your application's unique access patterns, preventing costly table scans.
  • Complex Data Modeling: Handles intricate relationships like one-to-many and hierarchical data (e.g., users, organizations, teams) with proven patterns.
  • Use Case: Imagine you're launching a new multi-tenant SaaS platform. Instead of spending days wrestling with DynamoDB design, this skill will instantly generate a robust, production-ready single-table schema for your users, organizations, and their data, ready for implementation.

Quick Start

Design a DynamoDB single-table schema for a social media application with users, posts, comments, and likes, ensuring efficient retrieval of a user's posts and all comments on a post.

Frequently Asked Questions about designing-dynamodb-tables

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I design a DynamoDB single-table schema for my application?

Single-table design co-locates related data using composite primary keys (partition and sort keys) and global secondary indexes to serve multiple access patterns efficiently. Define your access patterns first, then structure partition and sort keys to satisfy queries without table scans, minimizing cost and latency.

What are access patterns and why do they matter in DynamoDB schema design?

Access patterns are the specific queries your application needs to run—like fetching a user's posts or all comments on a post. DynamoDB schema design must anticipate these patterns upfront and create primary and secondary indexes that satisfy them directly, avoiding expensive full-table scans.

Can I store multiple entity types in a single DynamoDB table?

Yes. Single-table design stores users, posts, comments, and other entities in one table using entity-type prefixes in the sort key or a type attribute. This approach co-locates related data, reduces the number of tables, and improves query performance for hierarchical and one-to-many relationships.

How do I model one-to-many relationships like users and their posts in DynamoDB?

Use composite keys where the partition key identifies the parent entity (user ID) and the sort key differentiates children (e.g., 'POST#timestamp'). This groups all a user's posts together, enabling efficient range queries. Global secondary indexes can reverse the relationship if needed.

What's the difference between primary keys and global secondary indexes in DynamoDB?

Primary keys (partition and sort) define the main access path and determine table partitioning. Global secondary indexes create alternative key structures to support different queries—like retrieving posts by date when the primary key is user-centric. Each GSI incurs separate storage and write throughput costs.

When should I avoid single-table design for DynamoDB?

Single-table design suits applications with well-defined, limited access patterns and hierarchical data. Avoid it if your queries are highly unpredictable, require frequent full-table scans, or span disconnected entity types. Multiple tables may be simpler for loosely related data.