Drupal goes Social: Building a "Liking" Module in Drupal

You little complicated task.
Instead of writing custom js code you can use class ‘ajax-link’ and use ajax command. Here example how to use this features of Drupal http://www.computerminds.co.uk/drupal-code/make-link-use-ajax-drupal-7-its-easy . Also there is a little performance improvements: you need place nid column in primary key first then uid (some info about this: https://dev.mysql.com/doc/refman/5.0/en/multiple-column-indexes.html )
And of course you have problems with anonymous users (you can use session_api module if you want to give permission for anonymous users to vote).