I'm trying to implement a 3 table item tagging system
Table: Item
Columns: ItemID (primary, auto_increment), Title, Content
Table: Tag
Columns: TagID (primary, auto_increment), Title, TagCount
Table: ItemTag
Columns: ItemID, TagID
Each Title of a tag is unique.
I would like to implement an efficient way of inserting to the Tag table:
1. Check if Title exists
2. If it exists, update TagCount+1
3. Else if it doesn't exist, insert
I looked into INSERT ON DUPLICATE KEY UPDATE, but I'm confused if it can be applied because my key is the TagID and not the Title. Any help is appreciated, thank you.