How should I use DynamoDB table

database-designdynamodbjson

I have a list of items. Each item is attached to several urls and each url has a score number. So I have something like this :

enter image description here

How should I organise this in dynamoDB? How should I format my Json file to update my data?

Right now I'm using the first item column as a "partition key" and AttributeType as a number. I don't know how should I organise the rest. Maybe something like this : A { stuff : { URL : value, URL: value, URL: value} }. But with this structure I've hard time to update my table and I don't have experiences with this. I don't know the best practises, and I don't find any tutorial…

Thanks!

Best Answer

depending on how you want to fetch the data. If you want to get all by item, then item as a primary key is a great choice. If you want to filter by item and url then i would add primary key Item and sort key url. If you want to have url and search for the item by url, i would add url as primary key and url as sort key. If you want to be able to do both, i would add primary key for item, sort key for url and then add new GSI with primary key url and sort key item.

I learned a lot about this from this conference: https://www.youtube.com/watch?v=jzeKPKpucS0 recommended.