Skip to content

Instantly share code, notes, and snippets.

@garysassano
Created May 14, 2025 23:17
Show Gist options
  • Save garysassano/f886ea1ada28a29355ea05503a731995 to your computer and use it in GitHub Desktop.
Save garysassano/f886ea1ada28a29355ea05503a731995 to your computer and use it in GitHub Desktop.

PCComponentsData DynamoDB Table Structure

This document outlines the structure of the PCComponentsData DynamoDB table, including its primary key, sort key, Global Secondary Indexes (GSIs), and example items.

Table: PCComponentsData

PK (Partition Key) SK (Sort Key) Data Attribute (Example) GSI1PK (Type) GSI1SK (Brand#Model#ID) GSI2PK (Brand#Socket) GSI2SK (uArch#Model#ID) GSI3PK (SellerID) GSI3SK (Timestamp/Price) Item Type
COMP#CPU_AMD_R5_7600X METADATA Name: AMD Ryzen 5 7600X CPU AMD#Ryzen 5 7600X#CPU_AMD_R5_7600X AMD#AM5 Zen 4#Ryzen 5 7600X#CPU_AMD_R5_7600X Component
COMP#CPU_AMD_R5_7600X LISTING#bpm-power.com ItemPrice: 177.79 bpm-power.com 2023-10-27T10:30:00Z Listing
COMP#CPU_AMD_R5_7600X LISTING#nexths.it ItemPrice: 245.00 nexths.it 000245.00#2023-10-26T... Listing
COMP#CPU_AMD_R5_7600X BENCHMARK#GEEKBENCH6#SINGLECORE Value: 2750 Benchmark
COMP#CPU_AMD_R5_7600X BENCHMARK#GEEKBENCH6#MULTICORE Value: 12050 Benchmark
COMP#GPU_NVIDIA_RTX4070TI METADATA Name: NVIDIA GeForce RTX 4070 Ti GPU NVIDIA#RTX 4070 Ti#GPU_NVIDIA_RTX4070TI NVIDIA#RTX 40 Series (example) Ada Lovelace#RTX 4070 Ti#GPU_NVIDIA_RTX4070TI (example) Component
COMP#GPU_NVIDIA_RTX4070TI LISTING#amazon.de ItemPrice: 850.00 amazon.de 2023-10-27T11:00:00Z Listing
COMP#GPU_NVIDIA_RTX4070TI BENCHMARK#TIERLIST_GPU#GAMING_1440P Value: S_TIER Benchmark
SELLER#bpm-power.com METADATA Name: BPM-Power Seller
SELLER#nexths.it METADATA Name: Nexths.it Seller

Explanation of Columns:

  • PK (Partition Key):
    • COMP#<ComponentID>: For component metadata, its listings, and its benchmarks.
    • SELLER#<SellerID>: For seller metadata.
  • SK (Sort Key):
    • METADATA: For the main metadata item of a component or seller.
    • LISTING#<SellerID>: For a specific seller's listing of a component.
    • BENCHMARK#<SourceID>#<MetricName>: For a specific benchmark result of a component.
  • Data Attribute (Example): Shows a sample of other attributes stored in the item. The full list is in your ElectroDB models.
  • GSI1PK (Type):
    • Used by GSI1_Component_TypeBrandModel to query components by their type (e.g., all "CPU"s).
  • GSI1SK (Brand#ModelName#ComponentID):
    • Sort key for GSI1_Component_TypeBrandModel, allowing filtering/sorting by brand and model within a type.
  • GSI2PK (e.g., Brand#Socket for CPU):
    • Used by GSI2_Component_Hierarchy. The exact structure depends on the component Type (e.g., Brand#Series for GPUs).
  • GSI2SK (e.g., Microarchitecture#ModelName#ComponentID for CPU):
    • Sort key for GSI2_Component_Hierarchy, allowing further drill-down.
  • GSI3PK (SellerID):
    • Used by GSI3_Seller_Listings to query all listings by a specific seller.
  • GSI3SK (e.g., Timestamp or PaddedPrice#Timestamp):
    • Sort key for GSI3_Seller_Listings, allowing sorting of a seller's listings by time or price.
  • Item Type: A conceptual label for the kind of data the row represents.

Key Concepts Illustrated:

  1. Single Table Design: All different types of data (Components, Listings, Benchmarks, Sellers) reside in the same table.
  2. Composite Keys (PK & SK): Used to uniquely identify items and establish relationships.
  3. Adjacency List Pattern:
    • Listings and Benchmarks for a COMP#<ComponentID> are stored under the same PK, queryable with SK begins_with "LISTING#" or SK begins_with "BENCHMARK#".
    • This is also what ElectroDB's "collections" feature leverages.
  4. GSI Overloading (Conceptual): While not strictly overloading attributes in this example, GSIs are designed for specific query patterns:
    • GSI1: Find components by type, then filter/sort by brand/model.
    • GSI2: Hierarchical browsing (e.g., AMD -> AM5 -> Zen 4 -> Models).
    • GSI3: Find all listings from a particular seller.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment