ITWorker
ITWorker

Reputation: 995

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.

Upvotes: 3

Views: 4045

Answers (1)

gusto2
gusto2

Reputation: 12075

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.

Upvotes: 3

Related Questions