I want to store a list of items beloging to some parent object.
Parent Object would be like following:
user_id - hash key
timestamp - range key
attributeA - String
attributeB - Number
listC - List of objects
listC is a list of objects (like JSON), where each object can have a few fields:
attrX - number
attrY - string
attrZ - string
The size of the list can be varied, from few elements to hundreads.
How should I store them?
Due to DynamoDB's limits, I'm afraid that I cannot keep this list as an attribute of parent object. I think to move these lists to another table. However, I'm not sure if should I:
- keep each list's item as a separate record,
- split list's items to many separate records, where each database record has few items.
Approach (1):
-------------------------------------
| parent_id | attrX | attrY | attrZ |
-------------------------------------
| 178 | 2 | "abc" | "xyz" |
-------------------------------------
| 178 | 2.4 | "klm" | "qwe" |
-------------------------------------
Approach (2):
------------------------------------------------------------------------
| parent_id | Chunk | ListC |
------------------------------------------------------------------------
| 178 | 1 | [{ X: "2", Y: "abc" }, { X: "2.4", Y: "klm" } ] |
-------------------------------------------------------------------------
| 178 | 2 | [{ X: "2.8", Y: "nop" }, { X: "3.2", Y: "qrs" } ] |
------------------------------------------------------------------------
What would you recommend me?