A more general solution would be to have the second column in
the image lookup table contain a text category name, for example "football".
So for your game, two images would match if their category names are equal.
There are some more complex games, where images might match if
they have multiple categories (like sex, sport, color) associated with them
and the list of categories for the first image intersects with the list
of categories for the second image.
That would be a topic for another post.
ABG