I am currently thinking about how to structure my DynamoDB table(s).
I have following data structure:
{
UserId: string,
Id: string,
Date: string, //format: yyyy-mm-dd
From: string,
To: string,
Spent: string
}
So my purpose is to store hours of work.
I will query by UserId and Date. So I get the hours of work for the User which is logged in. For example: Query for 2017-09-12.
Or: Hours of work between 2017-08-12 and 2017-09-30
Hash Key: UserId,
Sort Key: Id (I want to query by date, but Hash Key and Sort Key must be unique)
Secondary Local Index: Date
My Question: should I split the table into multiple tables separated by month? When yes: There isn't a way to query over multiple table. So I have to find out which tables are required by the request and query them individual and join the results together?
Edit: And the tables I have to create automatically on the flow? So I have to check if the table already exists and if it doesn't I'll create it in the request?
I am refering to the Amazon DynamoDB docs:
the applications might show uneven access pattern across all the items in the table where the latest customer data is more relevant and your application might access the latest items more frequently and as time passes these items are less accessed, eventually the older items are rarely accessed. If this is a known access pattern, you could take it into consideration when designing your table schema. Instead of storing all items in a single table, you could use multiple tables to store these items. For example, you could create tables to store monthly or weekly data. For the table storing data from the latest month or week, where data access rate is high, request higher throughput and for tables storing older data, you could dial down the throughput and save on resources.
Amazon DynamoDB Guidelines for Tables
If you need more informations, please say it! Thanks in advance!