Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to specify the AWS SDK method to create a DynamoDB table.
DynamoDB
const params = { TableName: 'Users', KeySchema: [{ AttributeName: 'UserId', KeyType: 'HASH' }], AttributeDefinitions: [{ AttributeName: 'UserId', AttributeType: 'S' }], ProvisionedThroughput: { ReadCapacityUnits: 5, WriteCapacityUnits: 5 } };
dynamodb.[1](params, function(err, data) { if (err) console.log(err); else console.log(data); }); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'deleteTable' instead of 'createTable'.
Using 'listTables' which only lists existing tables.
✗ Incorrect
The method to create a DynamoDB table using AWS SDK is 'createTable'.
2fill in blank
mediumComplete the code to specify the primary key attribute type for the DynamoDB table.
DynamoDB
const params = { TableName: 'Orders', KeySchema: [{ AttributeName: 'OrderId', KeyType: 'HASH' }], AttributeDefinitions: [{ AttributeName: 'OrderId', AttributeType: '[1]' }], ProvisionedThroughput: { ReadCapacityUnits: 5, WriteCapacityUnits: 5 } }; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'BOOL' which is not valid for key attributes.
Using 'B' which stands for Binary but is less common.
✗ Incorrect
The primary key attribute type 'S' stands for String, which is commonly used for IDs.
3fill in blank
hardFix the error in the ProvisionedThroughput configuration by completing the missing property name.
DynamoDB
const params = { TableName: 'Products', KeySchema: [{ AttributeName: 'ProductId', KeyType: 'HASH' }], AttributeDefinitions: [{ AttributeName: 'ProductId', AttributeType: 'S' }], ProvisionedThroughput: { [1]: 10, WriteCapacityUnits: 10 } }; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'ReadUnits' which is not a valid property.
Using 'ReadCapacity' missing 'Units' suffix.
✗ Incorrect
The correct property name for read capacity is 'ReadCapacityUnits'.
4fill in blank
hardFill both blanks to define a global secondary index with a partition key and projection type.
DynamoDB
const params = { TableName: 'Employees', KeySchema: [{ AttributeName: 'EmployeeId', KeyType: 'HASH' }], AttributeDefinitions: [{ AttributeName: 'EmployeeId', AttributeType: 'S' }, { AttributeName: 'Department', AttributeType: 'S' }], GlobalSecondaryIndexes: [{ IndexName: 'DeptIndex', KeySchema: [{ AttributeName: '[1]', KeyType: 'HASH' }], Projection: { ProjectionType: '[2]' }, ProvisionedThroughput: { ReadCapacityUnits: 5, WriteCapacityUnits: 5 } }] }; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'EmployeeId' as index key which is the main table key.
Using 'KEYS_ONLY' when full attributes are needed.
✗ Incorrect
The global secondary index uses 'Department' as partition key and 'ALL' to project all attributes.
5fill in blank
hardFill all three blanks to create a DynamoDB table with a composite primary key and set throughput.
DynamoDB
const params = { TableName: 'Sales', KeySchema: [{ AttributeName: '[1]', KeyType: 'HASH' }, { AttributeName: '[2]', KeyType: 'RANGE' }], AttributeDefinitions: [{ AttributeName: '[1]', AttributeType: 'S' }, { AttributeName: '[2]', AttributeType: 'N' }], ProvisionedThroughput: { ReadCapacityUnits: 20, WriteCapacityUnits: 10 } }; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same attribute for both HASH and RANGE keys.
Mismatching attribute types in AttributeDefinitions.
✗ Incorrect
The composite key uses 'CustomerId' as partition key (HASH) and 'Timestamp' as sort key (RANGE). Both attributes are defined with correct types.