title: DynamoDB - Can it be used for data without a natural partition key?
body: <p>I was looking at DynamoDB to store some data because it looked like it might be a cost effective solution, but after a bit of research I think that it might not fit my use case because I am unable to find relevant unique values for partition and sort keys.</p>
  
  <p>My data are a series of records of natural events for various species of plants e.g. the date and location that someone noticed a Beech tree's leaves appearing.</p>
  
  <pre><code>{
    "species": "Beech",
    "event": "Budburst",
    "year": 2015,
    "season": "Spring",
    "date": "12/04/2015",
    "latitude": "0.00000",
    "longitude": "40.000"
  }
  </code></pre>
  
  <p>The main query for the application would be to obtain <strong>all</strong> of the data for a certain species for a certain event in a certain year:</p>
  
  <p>Endpoint: <code>events/:species/:event-type/:year</code></p>
  
  <p>This is likely to return a few thousand events which can then be shown in a map.</p>
  
  <p>If this were MongoDB, then I might create an index on a composite field of <code>species+eventType+year</code>. It wouldn't be a unique index, but at least only the few thousand results would be scanned rather than the whole table, so it wouldn't be too bad.</p>
  
  <p>I'm not sure how to achieve the same thing in DynamoDB, though, or even if it is possible, because the partition key, or the partition + sort key combination seems to have to be unique.</p>
  
  <p>Is the only way to make this work to have an incrementing unique event id for the partition key, and then have the <code>species+eventType+year</code> string as the sort key?</p>
  
  <p>If there are any other patterns I'd be grateful to hear about them.</p>
  
  <p>Thanks for reading.</p>