prevent sql error on catsevent import (issue #693)

+ ensures 'category event relation' key is unique
+ updates records if Replace is set
+ deletes all other relations of these events
+ uses same code when importing events with categories