Suppose the following DB migration in Ruby:
create_table :question_votes do |t| t.integer :user_id t.integer :question_id t.integer :vote
validates_uniqueness_of :user_id, :scope => [:question_id]
if you needed to include another column (or more), you can add that to the scope as well. Example:
validates_uniqueness_of :user_id, :scope => [:question_id, :some_third_column]