aws / aws-sdk-java

The official AWS SDK for Java 1.x (In Maintenance Mode, End-of-Life on 12/31/2025). The AWS SDK for Java 2.x is available here: https://github.com/aws/aws-sdk-java-v2/
https://aws.amazon.com/sdkforjava
Apache License 2.0
4.13k stars 2.83k forks source link

Single Table Design Pattern - Fetch only selected entities by giving begins_with or starts_with sort key #3086

Closed banandh closed 9 months ago

banandh commented 10 months ago

Describe the feature

Dynamo DB Java SDK batchGetItemRequest to support sort key starts_with/begins_with format also.

Use Case

SIngle Table design patter for a person is designed to store address, name, emails, phones, ids as separate entities which means PersonId is the sortKey and each address of that person will be added with different sort keys.The same way emails, phones and all the other person related entities are stored in table.

In one of the scenario, I need to pull person's all email and phone alone based on person Id. I will just have the person ID (PK) and email, Phone's sort key format alone not the exact sort key. so how to fetch selective entities based on PK and SK starts with?? I could see options to fetch completely based on PK but it will fetch entire data or giving exact sort key and retrieving it.

Proposed Solution

No response

Other Information

No response

Acknowledgements

AWS Java SDK version used

2.20.55

JDK version used

JDK17

Operating System and version

Ubuntu

debora-ito commented 9 months ago

I believe DynamoDB query provides what you're looking for. https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.KeyConditionExpressions.html

In the query operation, you provide the partition key, and define the filter expression that matches the sort key.