title: DynamoDB two sort keys with one as a date
body: <p>I have a primary key structure that is like this:</p>
  
  <pre>  
      <b>PRODUCT_ID</b>   <b>EFFECTIVE_DATE</b>   <b>SUB_PRODUCT_ID</b>
      1            19701231         1
      1            19701231         2
      1            19901231         1
      1            20081231         2
    </pre>
  
  <p>I would like to have this in DynamoDB, now I <em>think</em> the partition key of <strong>PRODUCT_ID</strong> makes sense and I <em>think</em> having the <strong>EFFECTIVE_DATE</strong> as the sort key makes sense.</p>
  
  <p>i.e. if I wanted to see the active entry where <strong>PRODUCT_ID</strong> = 1 and <strong>SUB_PRODUCT_ID</strong> = 1  that was effective on 19851231 this should return me the top entry.</p>
  
  <p>But I <em>think</em> I need <strong>SUB_PRODUCT_ID</strong> in the sort key as well, is that correct? The partition key and the sort key make up the primary key but these won't be unique without the <strong>SUB_PRODUCT_ID</strong>. </p>
  
  <p>I would like the ability to query on the date so I'm not sure if I should concatenate the <strong>EFFECTIVE_DATE</strong> and the <strong>SUB_PRODUCT_ID</strong> into a compound sort key.</p>
  
  <p>What is the right way to handle this?</p>
  
  <p>Thank you all!</p>