title: DynamoDB: How to store a list of items
body: <p>I want to store a list of items beloging to some parent object.</p>
  
  <p>Parent Object would be like following:</p>
  
  <pre><code>user_id - hash key
  timestamp - range key
  attributeA - String
  attributeB - Number
  listC - List of objects
  </code></pre>
  
  <p><strong>listC</strong> is a list of objects (like JSON), where each object can have a few fields:</p>
  
  <pre><code>attrX - number
  attrY - string
  attrZ - string
  </code></pre>
  
  <p>The size of the list can be varied, from few elements to hundreads.</p>
  
  <p><strong>How should I store them?</strong></p>
  
  <p>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:</p>
  
  <ol>
  <li>keep each list's item as a separate record,</li>
  <li>split list's items to many separate records, where each database record has few items.</li>
  </ol>
  
  <p>Approach (1):</p>
  
  <pre><code>-------------------------------------
  | parent_id | attrX | attrY | attrZ |
  -------------------------------------
  |  178      |  2    | "abc" | "xyz" |
  -------------------------------------
  |  178      | 2.4   | "klm" | "qwe" |
  ------------------------------------- 
  </code></pre>
  
  <p>Approach (2):</p>
  
  <pre><code>------------------------------------------------------------------------  
  | 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" } ] |
  ------------------------------------------------------------------------ 
  </code></pre>
  
  <p>What would you recommend me?</p>