I'm designing a new Table over DynamoDB. I already read some documentation but I'm not able to figure out which design schema should I follow to not have problems in a future.
Current Approach
Table - events
- eventId (HashKey)
- userId
- createdAt
- some other attributes...
Table - users
- userId (HashKey)
- name
- birth
- address
Events table are going to have a bunch of entries, like millions. Users are going to be about 20 entries at the moment.
I will need to perform the following queries:
- GET paginated events from specific userId ordered by createdAt
- GET paginated events from specific userId between some range of dates and ordered by createdAt
- GET specific event entry by eventId
So I thought to create a GSI (Global Secondary Index) on events table with the following setup:
- userId (HashKey)
- createdAt (RangeKey)
But my question here is: Do my initial design makes sense? Somehow I feel that I could design events table with the following setup:
- userId (HashKey)
- eventId (SortKey)
But I think that following this approach I would run into the Hot Partition Pitfall.
Some advices and recommendations would be appreciated.
Thanks.