I am “designing” a database layout. I have two different tables, containing two different types of data with different column requirements. I want to be able to attach zero or more images to each of the items in either table. It is unlikely that an image would be appropriate to be linked to an item in more than one of the tables, or to more than one item in the same table.
Is it better to have a single images table, with a column for the item id to which it is associated, and another column to indicate which of the two tables it is in, or to have two images tables, one to correspond with each of the initial two items tables?
I can see both ways - having a single large table for images seems “better”, but it does seem a bit messy to have to pick out which table they refer to. Though having said that, as the images are only referred to from their associated item, I doubt it would be an issue.
I think I’ve talked myself into a single images table there, but I’d be interested to hear opinions.