title: Uniqueness in DynamoDB secondary index
body: <p><strong>Question:</strong></p>
  
  <p>DynamoDB tables with a primary key that is a composite hash-range key are unique. Does this extend to secondary indices too?</p>
  
  <p><strong>Example:</strong></p>
  
  <p>I have a comments DynamoDB table with a <strong>post_id</strong> primary key and <strong>comment_id</strong> range key.
  Additionally there's a local secondary index with a <strong>date-user_id</strong> range key.</p>
  
  <p>Each entry is a comment a user has left on post. The purpose of the secondary index is to count how many unique users left a comment on a post on a specific day.</p>
  
  <p><strong>Entry 1</strong>:
  post_id: 1
  comment_id: 1
  date-user_id: 2014_06_24-1</p>
  
  <p><strong>Entry 2</strong>:
  post_id: 1
  comment_id: 2
  date-user_id: 2014_06_24-1</p>
  
  <p><strong>Entry 3</strong>:
  post_id: 1
  comment_id: 3
  date-user_id: 2014_06_24-2</p>
  
  <p>When I do a query specifying the secondary index, and pass in a condition of post_id equals 1 and a date-user_id equals 2014_06_24-1, I'm getting a count of 2 and I'm expecting a count of 1.</p>
  
  <p>Why does the secondary index have two entries with the same primary key/range key.</p>