I am inheriting DynamoDB from someone.
There is a table called Item. It used an item id as a partition key which is also primary key(no sort key in this table).
Each item has a Tags attribute which is a list like tag1, tag2, etc. Now, I got a new use case that I want to query item by tags efficiently. What is the best solution to this?
I am thinking creating another table for Tags which will be a partition key and item id becomes its sort key. Is it the best solution besides re-designing Item table?
Partition key(Primary key) tags. name other attributes....
id1 t1,t2. Item1Name ...
id2 t1,t3,t4,t5. Item2Name ...
...
My idea is to create another table, is it the best solution? any idea is appreciated.
Partition key(Primary key) sort key
t1 id1
t1 id2
t2 id1
t3 id2
t4 id2
t5 id2
...