I am setting up DynamoDB. Our data is simple, it has four fields:
- UserName
- UserShiftEndDate
- UserProjectCode
- UserActivities
Ideally, we should query the users based on the UserShiftEndDate
. None of the fields/combination in our data is unique. I can add an autogenerated ID for each record.
Please suggest me what fields to choose as partition key and sort key or GSI for optimal response time of query based on UserShiftEndDate
.
For an example, consider the table as below :
UserName | UserShiftEndDate | UserProjectCode | UserActivities |
---|---|---|---|
UserA | 12/13/2020 | 45 | monitoring |
UserB | 12/14/2020 | 47 | testing |
Userc | 12/17/2020 | 45 | monitoring |
UserB | 12/14/2020 | 45 | testing |
UserC | 12/15/2020 | 47 | managing |
My query should take the date as an input and should return all the users data with the shiftEndDate
later than or equal to the given date.
For example if 12/14/2020 is given as input, then the query should return all the user data except row 1.
We plan to store date in instant form. To make it simple, I mentioned it as date here
I would recommend creating a UUID (programmatically generated) as a primary key and then a GSI with the
UserShiftEndDate
. So that you can provide a date and get all the records that has the provided date. Please see this article for more information.