I used DynamoDB table with the following fields:
Primary Partition key => user_id
Primary Sort key => conversation_id
Sample table data
+---------+--------------------+
| user_id | conversation_id |
+---------+--------------------+
| 10 | aaaa |
| 10 | bbbb |
| 10 | cccc |
| 11 | aaaa |
| 11 | bbbb |
| 11 | cccc |
+---------+--------------------+
I have two separate queries in dynamodb:
- To fetch all
conversation_id
by particularuser_id
.
If Input 10 => Output => aaaa, bbbb, cccc - How to fetch all
user_id
from particularconversation_id
? If Input aaaa => Output => 10,11
I can get the result for 1st query, but how to fetch the 2nd query result.?
Is it a good practice to fetch data by using Primary Sort key(conversation_id
) or
How to assign or create conversation_id
as Global secondary index (Another Partition key)..?
Note: I am using PHP (Codeigniter framework)