Bird
Raised Fist0
DynamoDBquery~20 mins

First table creation in DynamoDB - Practice Problems & Coding Challenges

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Challenge - 5 Problems
🎖️
DynamoDB Table Creator
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
What is the output of this DynamoDB table creation command?
Consider this AWS CLI command to create a DynamoDB table named 'Books' with 'ISBN' as the partition key. What will be the result if the command runs successfully?
DynamoDB
aws dynamodb create-table --table-name Books --attribute-definitions AttributeName=ISBN,AttributeType=S --key-schema AttributeName=ISBN,KeyType=HASH --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5
ASyntax error due to missing sort key definition.
BTable 'Books' is created but with default throughput of 1 read and 1 write unit.
CTable 'Books' is created with 'ISBN' as the partition key and provisioned throughput of 5 read and 5 write units.
DError because 'ISBN' attribute type 'S' is invalid.
Attempts:
2 left
💡 Hint
Remember that DynamoDB requires at least a partition key and you can specify throughput explicitly.
📝 Syntax
intermediate
2:00remaining
Which option contains a syntax error in DynamoDB table creation?
Identify the option that will cause a syntax error when creating a DynamoDB table with a partition key 'UserId' of type string.
Aaws dynamodb create-table --table-name Users --attribute-definitions AttributeName=UserId,AttributeType=S --key-schema AttributeName=UserId,KeyType=HASH --provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1
Baws dynamodb create-table --table-name Users --attribute-definitions AttributeName=UserId,AttributeType=S --key-schema AttributeName=UserId,KeyType=HASH --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5
Caws dynamodb create-table --table-name Users --attribute-definitions AttributeName=UserId,AttributeType=S --key-schema AttributeName=UserId,KeyType=HASH --provisioned-throughput ReadCapacityUnits=10,WriteCapacityUnits=10
Daws dynamodb create-table --table-name Users --attribute-definitions AttributeName=UserId,AttributeType=String --key-schema AttributeName=UserId,KeyType=HASH --provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1
Attempts:
2 left
💡 Hint
Check the attribute type values allowed by DynamoDB.
🧠 Conceptual
advanced
2:00remaining
Why is a sort key optional when creating a DynamoDB table?
When creating a DynamoDB table, you can define a partition key alone or both a partition key and a sort key. Why might you choose to omit the sort key?
ABecause DynamoDB requires a sort key only for tables with more than 1000 items.
BBecause a partition key alone uniquely identifies each item, so a sort key is not always necessary.
CBecause the sort key is only used for indexing and does not affect uniqueness.
DBecause the sort key is deprecated and no longer supported in DynamoDB.
Attempts:
2 left
💡 Hint
Think about how DynamoDB uses keys to identify items.
query_result
advanced
2:00remaining
What is the output of this DynamoDB table creation with a composite key?
This command creates a table 'Orders' with 'OrderId' as partition key and 'OrderDate' as sort key. What will be the result?
DynamoDB
aws dynamodb create-table --table-name Orders --attribute-definitions AttributeName=OrderId,AttributeType=S AttributeName=OrderDate,AttributeType=S --key-schema AttributeName=OrderId,KeyType=HASH AttributeName=OrderDate,KeyType=RANGE --provisioned-throughput ReadCapacityUnits=10,WriteCapacityUnits=10
ATable 'Orders' is created with composite primary key (OrderId, OrderDate) and provisioned throughput of 10 read and 10 write units.
BError due to missing comma between attribute definitions.
CTable 'Orders' is created but only with 'OrderId' as key, ignoring 'OrderDate'.
DSyntax error because provisioned throughput values are too high.
Attempts:
2 left
💡 Hint
Check how multiple attributes and keys are defined in the command.
🔧 Debug
expert
2:00remaining
Why does this DynamoDB table creation command fail?
This command attempts to create a table 'Employees' with 'EmployeeId' as partition key. Why does it fail?
DynamoDB
aws dynamodb create-table --table-name Employees --attribute-definitions AttributeName=EmployeeId,AttributeType=N --key-schema AttributeName=EmployeeId,KeyType=HASH --provisioned-throughput ReadCapacityUnits=0,WriteCapacityUnits=5
ABecause ReadCapacityUnits cannot be zero; it must be at least 1.
BBecause attribute type 'N' is invalid for partition key.
CBecause the key schema is missing a sort key.
DBecause WriteCapacityUnits cannot be less than ReadCapacityUnits.
Attempts:
2 left
💡 Hint
Check the allowed values for provisioned throughput.

Practice

(1/5)
1. What is the minimum required element when creating a DynamoDB table?
easy
A. Table name and global secondary index
B. Table name and secondary index
C. Table name and primary key
D. Provisioned throughput only

Solution

  1. Step 1: Understand DynamoDB table basics

    Every DynamoDB table must have a unique name and a primary key to identify items.
  2. Step 2: Identify required elements for creation

    Secondary indexes and throughput settings are optional or have defaults, but primary key and table name are mandatory.
  3. Final Answer:

    Table name and primary key -> Option C
  4. Quick Check:

    Minimum required = Table name + primary key [OK]
Hint: Always specify table name and primary key first [OK]
Common Mistakes:
  • Forgetting to define the primary key
  • Confusing secondary index as mandatory
  • Omitting the table name
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 S
C. aws dynamodb create-table --table Users --primary-key UserId String
D. aws dynamodb make-table --table-name Users --key UserId --attribute-type S

Solution

  1. Step 1: Check AWS CLI syntax for create-table

    The correct command uses 'aws dynamodb create-table' with options: --table-name, --attribute-definitions, --key-schema, and --provisioned-throughput.
  2. Step 2: Verify option correctness

    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 correctly specifies attribute name and type, key schema with HASH key, and provisioned throughput. Others use invalid or incomplete syntax.
  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 full AWS CLI syntax with attribute-definitions and key-schema [OK]
Common Mistakes:
  • Using wrong command name like make-table
  • Missing attribute-definitions or key-schema
  • Incorrect option names like --name instead of --table-name
3. Given this AWS CLI command, what will be the primary key type of the table?
aws dynamodb create-table --table-name Products --attribute-definitions AttributeName=ProductId,AttributeType=N --key-schema AttributeName=ProductId,KeyType=HASH --provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1
medium
A. String
B. Binary
C. Boolean
D. Number

Solution

  1. Step 1: Identify attribute type in attribute-definitions

    The attribute ProductId is defined with AttributeType=N, which means Number.
  2. Step 2: Confirm key schema uses ProductId as HASH key

    The key schema uses ProductId as the partition key, so its type is Number.
  3. Final Answer:

    Number -> Option D
  4. Quick Check:

    AttributeType=N means Number [OK]
Hint: AttributeType=N means Number, S means String [OK]
Common Mistakes:
  • Confusing N with String type
  • Ignoring attribute-definitions
  • Assuming default type is String
4. You run this command but get an error:
aws dynamodb create-table --table-name Orders --attribute-definitions AttributeName=OrderId --key-schema AttributeName=OrderId,KeyType=HASH --provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1

What is the likely cause?
medium
A. Missing KeyType in key-schema
B. Missing AttributeType in attribute-definitions
C. Provisioned throughput values are too low
D. Table name is invalid

Solution

  1. Step 1: Check attribute-definitions syntax

    The attribute-definitions must include AttributeType (S, N, or B). Here, AttributeType is missing.
  2. Step 2: Verify other parts

    KeyType is present, throughput values are valid, and table name is valid. So the error is due to missing AttributeType.
  3. Final Answer:

    Missing AttributeType in attribute-definitions -> Option B
  4. Quick Check:

    AttributeType required in attribute-definitions [OK]
Hint: Always specify AttributeType with AttributeName [OK]
Common Mistakes:
  • Omitting AttributeType in attribute-definitions
  • Confusing KeyType with AttributeType
  • Assuming throughput values cause error
5. You want to create a DynamoDB table named Employees with a composite primary key: EmployeeId (string) as partition key and Department (string) as sort key. Which command correctly creates this table?
hard
A. aws dynamodb create-table --table-name Employees --attribute-definitions AttributeName=EmployeeId,AttributeType=S AttributeName=Department,AttributeType=S --key-schema AttributeName=EmployeeId,KeyType=HASH AttributeName=Department,KeyType=RANGE --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5
B. aws dynamodb create-table --table-name Employees --attribute-definitions EmployeeId=S Department=S --key-schema EmployeeId=HASH Department=RANGE --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5
C. aws dynamodb create-table --table Employees --attributes EmployeeId:string Department:string --keys EmployeeId:partition Department:sort --throughput 5 5
D. aws dynamodb create-table --table-name Employees --attribute-definitions AttributeName=EmployeeId,AttributeType=S --key-schema AttributeName=EmployeeId,KeyType=HASH --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5

Solution

  1. Step 1: Define attribute-definitions for both keys

    Both EmployeeId and Department must be defined with AttributeType=S.
  2. Step 2: Define key-schema with HASH and RANGE keys

    EmployeeId is partition key (HASH), Department is sort key (RANGE).
  3. Step 3: Check command syntax

    aws dynamodb create-table --table-name Employees --attribute-definitions AttributeName=EmployeeId,AttributeType=S AttributeName=Department,AttributeType=S --key-schema AttributeName=EmployeeId,KeyType=HASH AttributeName=Department,KeyType=RANGE --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 correctly uses --attribute-definitions and --key-schema with proper syntax and throughput.
  4. Final Answer:

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

    Composite key needs both keys in attribute-definitions and key-schema [OK]
Hint: List all keys in attribute-definitions and key-schema [OK]
Common Mistakes:
  • Defining only partition key without sort key
  • Incorrect key-schema syntax
  • Missing attribute definition for sort key