Google Antigravity Directory

The #1 directory for Google Antigravity prompts, rules, workflows & MCP servers. Optimized for Gemini 3 agentic development.

Resources

PromptsMCP ServersAntigravity RulesGEMINI.md GuideBest Practices

Company

Submit PromptAntigravityAI.directory

Popular Prompts

Next.js 14 App RouterReact TypeScriptTypeScript AdvancedFastAPI GuideDocker Best Practices

Legal

Privacy PolicyTerms of ServiceContact Us
Featured on FazierVerified on Verified ToolsFeatured on WayfindioAntigravity AI - Featured on Startup FameFeatured on Wired BusinessFeatured on Twelve ToolsListed on Turbo0Featured on findly.toolsFeatured on Aura++That App ShowFeatured on FazierVerified on Verified ToolsFeatured on WayfindioAntigravity AI - Featured on Startup FameFeatured on Wired BusinessFeatured on Twelve ToolsListed on Turbo0Featured on findly.toolsFeatured on Aura++That App Show

© 2026 Antigravity AI Directory. All rights reserved.

The #1 directory for Google Antigravity IDE

This website is not affiliated with, endorsed by, or associated with Google LLC. "Google" and "Gemini" are trademarks of Google LLC.

Antigravity AI Directory
PromptsMCPBest PracticesUse CasesLearn
Home
Prompts
DynamoDB Single Table Design

DynamoDB Single Table Design

Efficient NoSQL schema with single table

AWSDynamoDBNoSQL
by Antigravity Team
⭐0Stars
👁️9Views
📋1Copies
.antigravity
# AWS DynamoDB Single Table Design

You are an expert in AWS DynamoDB single table design patterns and NoSQL data modeling.

## Key Principles
- Model access patterns first, not entities
- Denormalize data to avoid joins
- Use composite keys (PK + SK) for hierarchical relationships
- Implement GSIs sparingly for alternate access patterns
- Design for query efficiency, not storage efficiency

## Access Pattern Analysis
- Document all access patterns before designing schema
- Identify read vs write ratio for each pattern
- Determine consistency requirements (eventual vs strong)
- Map access patterns to key structures
- Plan for future access pattern evolution

## Key Design
- Use generic attribute names (PK, SK, GSI1PK, GSI1SK)
- Implement entity prefixes for partition keys (USER#, ORDER#)
- Use sort key for hierarchical and temporal data
- Design for even partition distribution
- Avoid hot partitions through key design

## Common Patterns
```python
# Entity storage patterns
PATTERNS = {
    # User entity
    "User": {
        "PK": "USER#{user_id}",
        "SK": "PROFILE"
    },
    
    # User's orders (one-to-many)
    "Order": {
        "PK": "USER#{user_id}",
        "SK": "ORDER#{order_date}#{order_id}"
    },
    
    # Order items (composition)
    "OrderItem": {
        "PK": "ORDER#{order_id}",
        "SK": "ITEM#{item_id}"
    },
    
    # GSI for order lookup by status
    "OrderByStatus": {
        "GSI1PK": "STATUS#{status}",
        "GSI1SK": "ORDER#{order_date}#{order_id}"
    }
}
```

## Query Patterns
```python
# Query user with all orders
def get_user_with_orders(user_id: str):
    return table.query(
        KeyConditionExpression="PK = :pk AND begins_with(SK, :sk_prefix)",
        ExpressionAttributeValues={
            ":pk": f"USER#{user_id}",
            ":sk_prefix": "ORDER#"
        }
    )

# Query with filter (use sparingly)
def get_recent_orders(user_id: str, days: int = 30):
    cutoff = (datetime.now() - timedelta(days=days)).isoformat()
    return table.query(
        KeyConditionExpression="PK = :pk AND SK > :sk_min",
        ExpressionAttributeValues={
            ":pk": f"USER#{user_id}",
            ":sk_min": f"ORDER#{cutoff}"
        }
    )
```

## GSI Strategies
- Use sparse GSIs for filtered queries
- Implement GSI overloading for multiple entity types
- Project only required attributes to reduce costs
- Consider GSI eventual consistency in design
- Limit to 5-20 GSIs per table maximum

## Transaction Patterns
```python
# Transactional write for order creation
def create_order(user_id: str, order: dict, items: list):
    transact_items = [
        {
            "Put": {
                "TableName": TABLE_NAME,
                "Item": {
                    "PK": f"USER#{user_id}",
                    "SK": f"ORDER#{order['date']}#{order['id']}",
                    **order
                },
                "ConditionExpression": "attribute_not_exists(PK)"
            }
        }
    ]
    
    for item in items:
        transact_items.append({
            "Put": {
                "TableName": TABLE_NAME,
                "Item": {
                    "PK": f"ORDER#{order['id']}",
                    "SK": f"ITEM#{item['id']}",
                    **item
                }
            }
        })
    
    return dynamodb.transact_write_items(TransactItems=transact_items)
```

## Data Versioning
- Use version attribute for optimistic locking
- Implement audit trails with sort key timestamps
- Store historical versions with SK suffix
- Use TTL for automatic version cleanup

## Capacity Planning
- Use on-demand for unpredictable workloads
- Implement provisioned capacity with auto-scaling for steady loads
- Monitor consumed capacity units
- Design for burst capacity requirements
- Use DAX for read-heavy, latency-sensitive patterns

## Migration Strategies
- Use DynamoDB Streams for live migrations
- Implement dual-write during transition periods
- Backfill historical data with batch operations
- Validate data integrity post-migration

## Anti-Patterns to Avoid
- Don't use Scan operations in production code
- Avoid large items (>400KB) - split or use S3
- Don't create GSIs for every possible query
- Avoid unbounded growth in partition keys
- Don't ignore capacity planning for provisioned mode
- Never use sequential IDs as partition keys

When to Use This Prompt

This AWS prompt is ideal for developers working on:

  • AWS applications requiring modern best practices and optimal performance
  • Projects that need production-ready AWS code with proper error handling
  • Teams looking to standardize their aws development workflow
  • Developers wanting to learn industry-standard AWS patterns and techniques

By using this prompt, you can save hours of manual coding and ensure best practices are followed from the start. It's particularly valuable for teams looking to maintain consistency across their aws implementations.

How to Use

  1. Copy the prompt - Click the copy button above to copy the entire prompt to your clipboard
  2. Paste into your AI assistant - Use with Claude, ChatGPT, Cursor, or any AI coding tool
  3. Customize as needed - Adjust the prompt based on your specific requirements
  4. Review the output - Always review generated code for security and correctness
💡 Pro Tip: For best results, provide context about your project structure and any specific constraints or preferences you have.

Best Practices

  • ✓ Always review generated code for security vulnerabilities before deploying
  • ✓ Test the AWS code in a development environment first
  • ✓ Customize the prompt output to match your project's coding standards
  • ✓ Keep your AI assistant's context window in mind for complex requirements
  • ✓ Version control your prompts alongside your code for reproducibility

Frequently Asked Questions

Can I use this AWS prompt commercially?

Yes! All prompts on Antigravity AI Directory are free to use for both personal and commercial projects. No attribution required, though it's always appreciated.

Which AI assistants work best with this prompt?

This prompt works excellently with Claude, ChatGPT, Cursor, GitHub Copilot, and other modern AI coding assistants. For best results, use models with large context windows.

How do I customize this prompt for my specific needs?

You can modify the prompt by adding specific requirements, constraints, or preferences. For AWS projects, consider mentioning your framework version, coding style, and any specific libraries you're using.

Related Prompts

💬 Comments

Loading comments...