Search code examples
javatransactionsamazon-dynamodb

Is it possible to perfrom the following transaction with DynamoDB?


I am working with DynamoDB using Java. I have 2 tables with me, say Table1 and Table2.

Table1 has items with attributes like this: <attr1, attr2, attr3>

Table2 has items with attributes like this: <attr3, attr4, attr5>

[In the above 2 lines, the attributes in bold are partition keys and the ones in italic are range keys].

My API gets attr1 as input, using that I will have to access an item from Table1, then using the attr3 from the returned item, I will have to access an item from Table2 (I have the attr4 value available with me).

I want these 2 steps to be completed as a transaction.

Is it possible to perform this type of transaction in DynamoDB?

TransactionLoad, seems to be promising but I couldn't find a way to specify that I want a particular item from the Table1, using the attr1 value and then using the attr3 value obtained, get the item from Table2.


Solution

  • At first I would like to point that DynamoDB (or any non SQL) it's not suited for that kind of operations, and multiple tables: NoSQL Design for DynamoDB

    And about your question, the transactional read posibilities of DynamoDB are TransactGetItems, where you can read from multiple tables, but it´s not possible to make a transaction that read 1 table, and with the results read another, in fact by definition those are 2 transactions.