title: Social voting on Google App Engine
body: <p>I have an app where users can upvote or downvote a blog post. To implement the voting functionality, I created the below model ... </p>
  
  <pre><code> class Upvote(ndb.Model):
     user_id = ndb.IntegerProperty(required=True)
     blog_id = ndb.IntegerProperty(required=True)
  </code></pre>
  
  <p>When an user upvotes a post, I save it via:</p>
  
  <pre><code>Upvote(user_id=User.key.id(), blog_id=Blog.key.id()).put()
  </code></pre>
  
  <p>And to see if an user has already upvoted I query: </p>
  
  <pre><code>Upvote.query(Upvote.user_id=User.key.id(), Upvote.blog_id=Blog.key.id())
  </code></pre>
  
  <p>Is this the most efficient way to implement such a voting system? I want to make sure as it seems the <code>Upvote</code> model can get very large. Of course I am prematurely optimizing now but in a theoretical situation with millions of users I want the most efficient/cheapest method.</p>