Select rows which are not present in another table

Thanks, but I don’t understand what A.Key and B.Key should be. The “test_questions” table essentially contains pointers to the test and the question. Its schema has only three entries:

schema "test_questions" do
  belongs_to :test,     Test
  belongs_to :question, Question
  field      :position, :integer, null: false # question no. in the test, not question ID
end

The only relevant field that can be used as the key is question_id, which is never null.