Bird
Raised Fist0
AWScloud~10 mins

Creating a DynamoDB table in AWS - Interactive Practice

Choose your learning style10 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to specify the primary key attribute name for the DynamoDB table.

AWS
{
  "TableName": "MyTable",
  "KeySchema": [
    {
      "AttributeName": "[1]",
      "KeyType": "HASH"
    }
  ],
  "AttributeDefinitions": [
    {
      "AttributeName": "Id",
      "AttributeType": "S"
    }
  ],
  "ProvisionedThroughput": {
    "ReadCapacityUnits": 5,
    "WriteCapacityUnits": 5
  }
}
Drag options to blanks, or click blank then click option'
AId
BName
CPrimary
DKey
Attempts:
3 left
💡 Hint
Common Mistakes
Using an attribute name not defined in AttributeDefinitions.
Confusing KeyType values.
2fill in blank
medium

Complete the code to specify the attribute type for the primary key in DynamoDB.

AWS
{
  "TableName": "MyTable",
  "KeySchema": [
    {
      "AttributeName": "Id",
      "KeyType": "HASH"
    }
  ],
  "AttributeDefinitions": [
    {
      "AttributeName": "Id",
      "AttributeType": "[1]"
    }
  ],
  "ProvisionedThroughput": {
    "ReadCapacityUnits": 5,
    "WriteCapacityUnits": 5
  }
}
Drag options to blanks, or click blank then click option'
AN
BM
CS
DB
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'N' when the attribute is a string.
Using 'M' which is not a valid AttributeType.
3fill in blank
hard

Fix the error in the ProvisionedThroughput configuration by completing the missing value.

AWS
{
  "TableName": "MyTable",
  "KeySchema": [
    {
      "AttributeName": "Id",
      "KeyType": "HASH"
    }
  ],
  "AttributeDefinitions": [
    {
      "AttributeName": "Id",
      "AttributeType": "S"
    }
  ],
  "ProvisionedThroughput": {
    "ReadCapacityUnits": [1],
    "WriteCapacityUnits": 5
  }
}
Drag options to blanks, or click blank then click option'
A10000
B0
C-1
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Setting capacity units to zero or negative values.
Using excessively large numbers without justification.
4fill in blank
hard

Fill both blanks to add a sort key attribute named 'Timestamp' of type number.

AWS
{
  "TableName": "MyTable",
  "KeySchema": [
    {
      "AttributeName": "Id",
      "KeyType": "HASH"
    },
    {
      "AttributeName": "[1]",
      "KeyType": "RANGE"
    }
  ],
  "AttributeDefinitions": [
    {
      "AttributeName": "Id",
      "AttributeType": "S"
    },
    {
      "AttributeName": "Timestamp",
      "AttributeType": "[2]"
    }
  ],
  "ProvisionedThroughput": {
    "ReadCapacityUnits": 5,
    "WriteCapacityUnits": 5
  }
}
Drag options to blanks, or click blank then click option'
ATimestamp
BS
CN
DB
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'S' for a numeric attribute.
Mismatching attribute names between KeySchema and AttributeDefinitions.
5fill in blank
hard

Fill all three blanks to create a global secondary index named 'GSI1' with a partition key 'Category' of type string and provisioned throughput of 10 read and 5 write units.

AWS
{
  "TableName": "MyTable",
  "AttributeDefinitions": [
    {
      "AttributeName": "Id",
      "AttributeType": "S"
    },
    {
      "AttributeName": "Category",
      "AttributeType": "S"
    }
  ],
  "KeySchema": [
    {
      "AttributeName": "Id",
      "KeyType": "HASH"
    }
  ],
  "GlobalSecondaryIndexes": [
    {
      "IndexName": "[1]",
      "KeySchema": [
        {
          "AttributeName": "[2]",
          "KeyType": "HASH"
        }
      ],
      "Projection": {
        "ProjectionType": "ALL"
      },
      "ProvisionedThroughput": {
        "ReadCapacityUnits": [3],
        "WriteCapacityUnits": 5
      }
    }
  ],
  "ProvisionedThroughput": {
    "ReadCapacityUnits": 5,
    "WriteCapacityUnits": 5
  }
}
Drag options to blanks, or click blank then click option'
AGSI1
BCategory
C10
DId
Attempts:
3 left
💡 Hint
Common Mistakes
Using the table's primary key attribute as the GSI partition key.
Setting incorrect provisioned throughput values.

Practice

(1/5)
1. What is the main purpose of the primary key when creating a DynamoDB table?
easy
A. To define the table's read capacity
B. To store the table's name
C. To specify the AWS region
D. To uniquely identify each item in the table

Solution

  1. Step 1: Understand the role of the primary key

    The primary key uniquely identifies each item in a DynamoDB table, ensuring no duplicates.
  2. Step 2: Differentiate from other table properties

    Table name, capacity, and region do not serve as unique identifiers for items.
  3. Final Answer:

    To uniquely identify each item in the table -> Option D
  4. Quick Check:

    Primary key = unique item ID [OK]
Hint: Primary key means unique ID for each item [OK]
Common Mistakes:
  • Confusing primary key with table name
  • Thinking capacity defines uniqueness
  • Mixing region with key attributes
2. Which AWS CLI command correctly creates a DynamoDB table named Users with a primary key UserId of type string?
easy
A. aws dynamodb create-table --table-name Users --attribute-definitions AttributeName=UserId,AttributeType=S --key-schema AttributeName=UserId,KeyType=HASH --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5
B. aws dynamodb create-table --name Users --key UserId --type String
C. aws dynamodb make-table --table Users --key UserId --type S
D. aws dynamodb create-table --table Users --attribute UserId String --key UserId HASH

Solution

  1. Step 1: Identify correct AWS CLI syntax for creating a table

    The correct command uses create-table with --table-name, --attribute-definitions, --key-schema, and --provisioned-throughput.
  2. Step 2: Verify attribute and key schema details

    AttributeName=UserId with AttributeType=S (string) and KeyType=HASH for primary key is correct.
  3. Final Answer:

    aws dynamodb create-table --table-name Users --attribute-definitions AttributeName=UserId,AttributeType=S --key-schema AttributeName=UserId,KeyType=HASH --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 -> Option A
  4. Quick Check:

    Correct CLI syntax = aws dynamodb create-table --table-name Users --attribute-definitions AttributeName=UserId,AttributeType=S --key-schema AttributeName=UserId,KeyType=HASH --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 [OK]
Hint: Use --attribute-definitions and --key-schema for keys [OK]
Common Mistakes:
  • Using wrong command like make-table
  • Missing provisioned throughput
  • Incorrect flags like --name instead of --table-name
3. Given this AWS CLI command:
aws dynamodb create-table --table-name Products --attribute-definitions AttributeName=ProductId,AttributeType=S AttributeName=Category,AttributeType=S --key-schema AttributeName=ProductId,KeyType=HASH AttributeName=Category,KeyType=RANGE --provisioned-throughput ReadCapacityUnits=10,WriteCapacityUnits=5

What is the primary key type of the Products table?
medium
A. No primary key defined
B. Simple primary key with only a HASH key
C. Composite primary key with HASH and RANGE keys
D. Primary key with only a RANGE key

Solution

  1. Step 1: Analyze the key schema in the command

    The command defines two keys: ProductId as HASH and Category as RANGE.
  2. Step 2: Understand primary key types in DynamoDB

    A primary key with both HASH and RANGE keys is called a composite primary key.
  3. Final Answer:

    Composite primary key with HASH and RANGE keys -> Option C
  4. Quick Check:

    HASH + RANGE = composite key [OK]
Hint: HASH + RANGE keys mean composite primary key [OK]
Common Mistakes:
  • Thinking two attributes mean no key
  • Confusing RANGE key as standalone primary key
  • Ignoring key-schema details
4. You run this command to create a DynamoDB table:
aws dynamodb create-table --table-name Orders --attribute-definitions AttributeName=Id,AttributeType=N --key-schema AttributeName=OrderId,KeyType=HASH --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5

But you get an error. What is the most likely cause?
medium
A. The attribute definition and key schema attribute names do not match
B. Provisioned throughput values are missing
C. The key schema is missing a RANGE key
D. AttributeType should be 'S' for string, not 'N' for number

Solution

  1. Step 1: Check attribute definitions and key schema names

    The attribute definitions specify AttributeName=Id, but the key schema specifies AttributeName=OrderId. The names do not match, causing the error.
  2. Step 2: Verify other potential issues

    Provisioned throughput values are present (not B), a simple primary key with only HASH is allowed (not C), AttributeType=N is valid for numeric IDs (not D).
  3. Final Answer:

    The attribute definition and key schema attribute names do not match -> Option A
  4. Quick Check:

    Attribute names must match exactly [OK]
Hint: Match attribute names exactly in definitions and key schema [OK]
Common Mistakes:
  • Assuming 'N' type is invalid
  • Expecting RANGE key for all tables
  • Missing provisioned throughput
5. You want to create a DynamoDB table named Sessions with a composite primary key: UserId (string) as HASH and SessionId (string) as RANGE. You also want to set autoscaling for read and write capacity. Which of the following is the best approach?
hard
A. Create the table without specifying key schema and add keys later
B. Use aws dynamodb create-table with attribute definitions and key schema, then configure autoscaling via Application Auto Scaling service
C. Use aws dynamodb create-table with only HASH key and enable autoscaling in the same command
D. Create the table with fixed provisioned throughput and manually update capacity when needed

Solution

  1. Step 1: Define table with composite primary key

    Use create-table with attribute definitions for UserId and SessionId, and key schema with HASH and RANGE keys.
  2. Step 2: Configure autoscaling separately

    DynamoDB autoscaling is set up via Application Auto Scaling service after table creation; it cannot be enabled directly in create-table command.
  3. Final Answer:

    Use aws dynamodb create-table with attribute definitions and key schema, then configure autoscaling via Application Auto Scaling service -> Option B
  4. Quick Check:

    Composite key + separate autoscaling setup = Use aws dynamodb create-table with attribute definitions and key schema, then configure autoscaling via Application Auto Scaling service [OK]
Hint: Create table first, then set autoscaling separately [OK]
Common Mistakes:
  • Trying to enable autoscaling in create-table command
  • Skipping RANGE key for composite key
  • Creating table without key schema
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard