0

Is there we can ensure uniqueness in a non-key attribute for a given partition key in DynamoDB.

For eg: We have person_id as the partition key and category#UUID as the sort key and we another attribute called category#effectiveDate. Now effectiveDate is mutable that is why we have not used this as sort key. But we also want to maintain ensure for a given person_id, category#effectiveDate remains unqiue. How can we do it?

1 Answer 1

2

There is only one way to achieve this and it's by using a second table and Transactions, where the category#UUID is a partition key on the second table.

Fully explained in this blog post.

4
  • Why can't query LSI on category#effectiveDate work in same transaction?
    – itisha
    Commented Jul 6 at 5:59
  • LSI does not maintain uniqueness. Commented Jul 6 at 13:36
  • No but I can query LSI made against category#effectiveDate before inserting in DB as I know partition key. Won't this work?
    – itisha
    Commented 2 days ago
  • If you're building a single threaded application, then it might be ok. Commented 2 days ago

Not the answer you're looking for? Browse other questions tagged or ask your own question.