I have these 3 tables + data:
items: itemId, itemName
data: 1, my item one
categories: catId, catName
data: 1, my cat one. 2, my cat two
map: mapId, itemId, catId
When you include item "my item one" in category "my cat one", you insert [1, 1, 1] into the map. When you add "my item one" to "my cat two", you insert [2, 1, 2] into the map. Now let's say we change our mind and only want the item in "my cat two". This means we need to know what categories the item is no longer in and delete the associations from the map. What's the most efficient sequence of steps to take to do so? (I'm looking for a solution that will scale beyond this trivial example.)