First, I'm new to DyanmoDB and would like to use it for a little side project to get familiar with it. I've started reading some online documentation and blogs. However, some of the stuff isn't fully clear to me yet.
Use case: I would like to store only two (for the moment), time series in DynamoDB. One will be an inflation rate and one will be an interest rate. I will have a lambda function which fetches these data from the web on an ongoing basis and stores the new value of each to the DynamoDB. My application is then always using the latest available value of this rates. The frequency they are sourced is rather slow, not more often than on a weekly basis.
For this I wanted to use the following schema (serverless.yml)
resources: # CloudFormation template syntax from here on.
Resources:
usersTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: RatesTable
AttributeDefinitions:
- AttributeName: RateType
AttributeType: S
- AttributeName: SourcedOn
AttributeType: Date
- AttributeName: Tenor
AttributeType: S
- AttributeName: Rate
AttributeType: N
KeySchema:
- AttributeName: RateType
KeyType: HASH
- AttributeName: SourcedOn
KeyType: RANGE
Is this a reasonable schema / setup to choose. What I'm not so sure is what to use for the SourcedOn
attribute. Is Date
type the right, or should I use a integer in the format of 20190101
?. This last question is also in hinsight of using python to query and I'm always and only interested in reading the latest sourced value per RateType
Is there a way to retrieve (without knowing which date exactly) the last sourced rate with boto? How would such a query look like?