I am fairly new to DynamoDB. I have a requirement where I need to design a table to share codes on cellphones. The code details will be stored as attributes. For example:
- 'A' shared a code to '1234567890'
- 'A' shared a code to '1234567891'
- 'B' shared a code to '1234567890'
- 'B' shared a code to '1234567891'
'A' and 'B' are users '1234567890' and '1234567891' are the recipients. If I make UserId hash key and RecipientNumber as range key, I can find out the recipients with whom the user shared the code. My requirement is to query both ways: 1. Recipients list with whom a user has shared codes(Passing userId in query) 2. List of codes shared with a recipient(by all the users who have shared code with the recipient)
What should be the correct way to design the table?