I am new to DynamoDb and I did look at the AWS documentation and some of the questions regarding Hash and Range keys. After all that, I am still not sure what exactly they mean and why/how would you use them. Can someone give me a simple explanation with an example?
For example, If I want to create a Movie
table with Name
, Genre
, Rating
and DateReleased
columns. What would be the correct way to create the DynamoDb table. In the example below, I have got some CloudFormation to try and create the following but I am not sure if I have used the KeySchema property correctly. Any help would be appreciated.
MovieTable:
Type: AWS::DynamoDB::Table
Properties:
BillingMode: PAY_PER_REQUEST
AttributeDefinitions:
- AttributeName: "Name"
AttributeType: "S"
- AttributeName: "Genre"
AttributeType: "S"
- AttributeName: "Rating"
AttributeType: "N"
- AttributeName: "DateReleased"
AttributeType: "S"
KeySchema:
- AttributeName: "Name"
KeyType: "HASH"
- AttributeName: "Genre"
KeyType: "RANGE"
- AttributeName: "Rating"
KeyType: "RANGE"
- AttributeName: "DateReleased"
KeyType: "RANGE"
TimeToLiveSpecification:
AttributeName: ExpireAfter
Enabled: false
SSESpecification:
SSEEnabled: true