Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DynamoDB larger than 400KB items

I am planning to create a merchant table, which will have store locations of the merchant. Most merchants are small businesses and they only have a few stores. However, there is the odd multi-chain/franchise who may have hundreds of locations.

What would be my solution if I want to put include location attributes within the merchant table? If I have to split it into multiple tables, how do I achieve that?

Thank you!

EDIT: How about splitting the table. To cater for the majority, say up to 5 locations I can place them inside the same table. But beyond 5, it will spill over to a normalised table with an indicator on the main table to say there are more than 5 locations. Any thoughts on how to achieve that?

like image 385
Bluetoba Avatar asked May 07 '18 01:05

Bluetoba


1 Answers

You have a couple of options depending on your access patterns:

  • Compress the data and store the binary object in DynamoDB.
  • Store basic details in DynamoDB along with a link to S3 for the larger things. There's no transactional support across DynamoDB and S3 so there's a chance your data could become inconsistent.
  • Rather than embed location attributes, you could normalise your tables and put that data in a separate table with the equivalent of a foreign key to your merchant table. But, you may then need two queries to retrieve data for each merchant, which would count towards your throughput costs.
  • Catering for a spill-over table would have to be handled in the application code rather than at the database level: if (store_count > 5) then execute another query to retrieve more data

If you don't need the performance and scalability of DynamoDB, perhaps RDS is a better solution.

like image 153
craigcaulfield Avatar answered Nov 03 '22 02:11

craigcaulfield