Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamic attributes in DynamoDB?

I am learning about DynamoDB and one of the benefits I have read about NoSQL is that the data does not need to be standardized. I was wondering if it is possible in Java to support inserting into a DynamoDB table with an unknown number and type of attributes. Is there any way in the DynamoDBMapper or JPA that supports this? For example, reading form a Spreadsheet that contains different columns depending on the sheet, but is guaranteed to have two specific columns (hash and range) regardless.

Thank you.

like image 485
ITWorker Avatar asked Jun 07 '26 08:06

ITWorker


1 Answers

Is there any way in the DynamoDBMapper or JPA that supports this

JPA (or generally any object mapping framework) would map strongly typed objects into the DynamoDB, so the database provides more flexibility than the object framework, no issue in that

While you work with fixed objects, the DynamoDBMapper seems to be good choice

Spreadsheet that contains different columns depending on the sheet

Lets assume you don't know the sheet columns upfront and you need to store 'any column' that you encounter.

IMHO you would have no easy way to map 'any column' into strongly typed Java objects, for that use case I see the best fit a key/value map.

As far I know you cannot store a Map attribute with the DynamoDBMapper (please correct me if I am wrong) , so for working with flexible schema I'd skip JPA or mapper layer completely.

like image 169
gusto2 Avatar answered Jun 10 '26 18:06

gusto2



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!