I have a table for images.
I have tables for entities such as people, cars, houses, trains and dogs to which I need to assign images.
I need to assign images to entities. The obvious solution is to create many many-many tables:
people_images (person_id, image_id, sort_position, ...) cars_images (car_id, image_id, sort_position, ...) houses_images (house_id, image_id, sort_position, ...)
And perhaps modify the images table like so:
images (image_id, url, is_person_image, is_cars_image, is_houses_image, ...)
I am wondering if there is a better solution or common pattern for this.