I was looking at a tutorial on triggers for SQLite. The tutorial said that a use of triggers could be for data validation.
The following code was given as an example:
CREATE TRIGGER validate_email_before_insert_leads BEFORE INSERT ON leads BEGIN SELECT CASE WHEN NEW.email NOT LIKE '%_@__%.__%' THEN RAISE (ABORT, 'Invalid email address') END; END;
My first inclination would be to use a check constraint for validation instead. I did a Google search for situations where one should use a check constraint and when a trigger would be preferable.
My question is, what specific situations should one use a check constraint and what situations should one opt to use a trigger?