Skip to main content
InterviewHubPRO
Section Overview
Q14

Question 14 of 50

Part 2: Intermediate Data Modeling & API Operations (Mid-Level)

28%
Amazon DynamoDB (50 Qs)•Part 2: Intermediate Data Modeling & API Operations (Mid-Level)

How do you implement PK and SK Overloading in Single-Table Design?

mid LevelCode ExampleDynamoDBHTTP & REST APIs

In Simple Words: Entities share standard PK and SK string names using colon or hashtag delimiters:

  • User Profile: PK = "USER#42", SK = "PROFILE#42"
  • User Order: PK = "USER#42", SK = "ORDER#2026-03-15#991"
  • Order Item: PK = "ORDER#991", SK = "ITEM#SKU-772"
  • Global Index GSI1: GSI1_PK = "STATUS#PENDING", GSI1_SK = "DATE#2026-03-15"
typescript
// Fetching User Profile AND Recent Orders in 1 Query:
const query = new QueryCommand({
  TableName: "ECommerceApp",
  KeyConditionExpression: "PK = :userPk AND SK begins_with(:prefix)",
  ExpressionAttributeValues: {
    ":userPk": { S: "USER#42" },
    ":prefix": { S: "ORDER#" }
  }
});