dynamodb-single-table

Model users, posts, and metadata in a single DynamoDB table with generic keys and GSIs.

1|Updated Aug 7, 2024
One-click install
npx skills add https://github.com/tejovanthn/rasikalife --skill dynamodb-single-table
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dynamodb-single-table
Source: https://github.com/tejovanthn/rasikalife/tree/main/.opencode/skill/dynamodb-single-table
Command: npx skills add https://github.com/tejovanthn/rasikalife --skill dynamodb-single-table

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Single-table design is a DynamoDB pattern that avoids many tables by modeling diverse entities (users, posts, metadata) in one table with well-chosen partition and sort keys. This skill explains the approach, key concepts, and practical patterns to design scalable, cost-effective data models.

Core Features & Use Cases

  • Unified data model: model users, posts, and related entities in a single table with generic keys (pk, sk) and carefully chosen GSIs.
  • Access-pattern driven design: Get, Query, and GSI-based lookups built around common queries like "get user profile" or "list a user's posts".
  • Practical guidance: step-by-step patterns for item collections, metadata, and denormalization to support serverless SST apps.

Quick Start

Initialize a DynamoDB single-table schema by defining keys for USER#<id>, POST#<postId>, and METADATA for a given item, then perform a Get on USER#123 PROFILE and a Query for POST# by that user.

Frequently Asked Questions about dynamodb-single-table

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

FAQPage Schema
What is DynamoDB single-table design and when do I need it?

DynamoDB single-table design is a data modeling pattern that consolidates multiple entities into one table using generic keys. You need it to achieve fast, scalable access patterns for users, posts, and metadata in serverless SST apps.

How do I model multiple entities in a single DynamoDB table?

Model multiple entities in a DynamoDB single table by defining generic keys such as USER#<id> for partitions and POST#<postId> for sort keys. Combine this with carefully chosen GSIs to enable access-pattern driven queries.

Can I use this single-table data modeling approach with an SST setup?

Yes, this single-table data modeling approach applies directly to serverless SST setups. It provides practical, step-by-step patterns for item collections and denormalization to support fast, scalable SST workloads.

What's the best way to query a user's profile and posts in DynamoDB?

The best way to query a user's profile and posts in DynamoDB is through access-pattern driven design. Perform a Get on USER#<id> PROFILE and a Query for POST# items by that user using composite keys and GSIs.

Why use a single DynamoDB table instead of multiple tables for different entities?

Use a single DynamoDB table instead of multiple tables to achieve a scalable, cost-effective data model. Single-table design uses well-chosen partition and sort keys to satisfy generic key requirements and GSI-aware access patterns efficiently.