There is a MySQL database with the following table reviews(reviewer, product, score, title, comment, creation_date, last_modified). It is needed a trigger before insertion to check if the user has already reviewed the same product. If so, just update the fields score, title, comment and last_modified. This mean no insertion. Otherwise no operation is needed from the trigger and the review is inserted as usually.
N.B. primary key is bold, foreign key is italic
I tried something myself but I am confident enough to say it does not work:
CREATE TRIGGER update_review BEFORE INSERT ON reviews
FOR EACH ROW
IF ((SELECT reviews.reviewer, reviews.product FROM reviews WHERE reviews.reviewer=new.reviewer AND reviews.product=new.product)) THEN
SET old.score=new.score AND old.title=new.title AND old.comment=new.comment AND old.last_modified=new.last_modified;