I am trying to set up a normalised MySQL database containing the three following tables. The first table contains a list of items which can be described by various tags. T
This mapping-table concept is pretty standard and looks well-implemented here. The only thing I'd change is getting rid of the ID in Table 2; for what would you use it? Just make a joint key for Table 2 on both item ID and tag ID.
Actually, selecting where an item matches ALL tags is hard. Try this:
SELECT item_id,COUNT(tag_id) FROM Table2 WHERE tag_id IN (your set here) GROUP BY item_id
Where the count equals the number of tag IDs in your set, you have found a match.