What is the most efficient way add a constraint in my MySQL table in order to reject the 3rd insert of the same type?
CREATE TABLE `stack_over_t` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`data` varchar(45) NOT NULL,
`category` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`)
)
Ideally I would like to block an insert (trigger before insert?) with category=1, since there are already two entries with category 1. How can I do this? Can I extend it to more than one column?