I want to make a column in a relation unmodifyable for consistency reasons.
The backstory is that I have a n:n relationship where the "connecting" relation has additional values. I don't want that anyone is able to change the IDs of the relationship partners.
What I have come up with so far:
Creating a trigger that checks if the NEW value is the same as the OLD value. But I don't know how to deny the UPDATE action if the condition proves as TRUE.
Here is my trigger so far:
CREATE TRIGGER deny_nton_change BEFORE UPDATE ON Schueler_in_Klasse FOR EACH ROW BEGIN IF NEW.Schueler_ID != OLD.Schueler_ID OR NEW.Klasse_ID != OLD.Klasse_ID THEN END IF; END;