title: database design for voting system
body: <p>I need to store votes for items (by id) in a system. I estimate it's gonna have about 5 million votes.
  Each vote consists of:</p>
  
  <ul>
  <li>id of the voted item</li>
  <li>userdata1</li>
  <li>userdata2</li>
  <li>datetime</li>
  </ul>
  
  <p>"userdata" fields will be used to detect cheaters in the end of the voting. During the voting all votes should be registered.</p>
  
  <p>I need to be able to retrieve 2 kinds of information:</p>
  
  <ul>
  <li>about each 1 minute) how many votes each "id of the voted item" has</li>
  <li>about each 1 hour) how many votes each "id of the voted item" has after applying some filters to "userdata" fields (like both must be unique in a certain datetime interval, or something like that)... I don't wanna need to able to write those filters in form of an SQL query... I want to iterate over all ~5 million votes and create a new table/data structure that will have the result and then return it to the application</li>
  </ul>
  
  <p>INSERTions of votes shouldn't be a big deal (it's about 2 per second, so I guess any DB can handle it pretty well)</p>
  
  <p>I'm leaning toward something like mongoDB because of the "scripting" needed for the iterating over DB and creating a filter. But maybe it can be solved with SQL on a stored procedure, or a key-value (Redis? 5mi votes should fit in less than 2 GBs RAM) DB?</p>