BooksISBN as the partition key (string type)Edition as the sort key (number type)Title (string type) to store the book titleJump into concepts and practice - no test required
BooksISBN as the partition key (string type)Edition as the sort key (number type)Title (string type) to store the book titletable_name and set it to the string 'Books'. Then create a dictionary called key_schema with one entry: a dictionary with AttributeName set to 'ISBN' and KeyType set to 'HASH'.The partition key is called the HASH key in DynamoDB. Use a list with one dictionary for key_schema.
key_schema list with AttributeName set to 'Edition' and KeyType set to 'RANGE' to define the sort key.The sort key is called the RANGE key in DynamoDB. Add it as the second item in the key_schema list.
attribute_definitions with two dictionaries: one for ISBN with AttributeType set to 'S' (string), and one for Edition with AttributeType set to 'N' (number).Attribute types use 'S' for string and 'N' for number in DynamoDB.
table_params with keys: TableName set to table_name, KeySchema set to key_schema, AttributeDefinitions set to attribute_definitions, and BillingMode set to 'PAY_PER_REQUEST'.Use PAY_PER_REQUEST billing mode for simplicity.
What is a composite primary key in DynamoDB?
Which of the following is the correct way to define a composite primary key in DynamoDB table creation?
{
"TableName": "Orders",
"KeySchema": [
{"AttributeName": "CustomerId", "KeyType": "HASH"},
{"AttributeName": "OrderDate", "KeyType": "RANGE"}
]
}Given a DynamoDB table with composite primary key (UserId as PartitionKey, Timestamp as SortKey), what will this query return?
{
"TableName": "UserActivity",
"KeyConditionExpression": "UserId = :uid and Timestamp > :time",
"ExpressionAttributeValues": {
":uid": {"S": "user123"},
":time": {"N": "1609459200"}
}
}What is wrong with this DynamoDB query using composite primary key (UserId as PartitionKey, OrderId as SortKey)?
{
"TableName": "Orders",
"KeyConditionExpression": "OrderId = :oid",
"ExpressionAttributeValues": {
":oid": {"S": "order789"}
}
}You want to store blog posts in DynamoDB. Each post has a AuthorId and a PostDate. You want to quickly find all posts by an author sorted by date. Which composite primary key design is best?