2
votes

I understand we can't use DynamoDB as regular relational databases, but I have a feeling some of my use cases can be modeled using the extra features DynamoDB has.

I'm extending the table example from the documentation here: http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GuidelinesForTables.html

If I model my table as:

UserID    MessageID    MessageMetaData MessageRetried

U1          M1              XYZ1            True

U1          M2              XYZ2            True

U1          M3              XYZ3            False

U2          M1              ABC1            True

U2          M2              ABC2            False

U3          M1              QWE1            False

U3          M2              QWE2            True

If I make a the partition(primary) key as the UserID field and the sort key as MessageID.

I understand if I query for just the UserID U1, I would get the list containing all these items [{U1, M1, XYZ1}, {U2, M2, XYZ2}, {U3, M3, XYZ3}]. What is the best way to do this in the Java High Level API?

Also, if I pass both UserID and MessageId, I should be able to just get that item.

Now, if I assume I create a GlobalSecondaryIndex on MessageRetried, then from my understanding I can fetch all items that have the value as true, but this limited by a page size, is there a way to paginate the response of this?

Thanks, Abeer

1

1 Answers

3
votes

Using only partition key is called Query and having both partition and sort key is called Get because you have the full primary key of an item.

If you query for A LOT of items, you get a paginated result by definition. Which means that if you keep on iterating over it, you will eventually get all elements.