CREATE TABLE sales ( id INT AUTO_INCREMENT, product VARCHAR(100) NOT NULL, quantity INT NOT NULL DEFAULT 0, fiscalYear SMALLINT NOT NULL, fiscalMonth TINYINT NOT NULL, CHECK(fiscalMonth >= 1 AND fiscalMonth <= 12), CHECK(fiscalYear BETWEEN 2000 and 2050), CHECK (quantity >=0), UNIQUE(product, fiscalYear, fiscalMonth), PRIMARY KEY(id) ); INSERT INTO sales(product, quantity, fiscalYear, fiscalMonth) VALUES ('2003 Harley-Davidson Eagle Drag Bike',120, 2020,1), ('1969 Corvair Monza', 150,2020,1), ('1970 Plymouth Hemi Cuda', 200,2020,1); DELIMITER $$ CREATE TRIGGER before_sales_update BEFORE UPDATE ON sales FOR EACH ROW BEGIN DECLARE errorMessage VARCHAR(255); SET errorMessage = CONCAT('The new quantity ', NEW.quantity, ' cannot be 3 times greater than the current quantity ', OLD.quantity); IF new.quantity > old.quantity * 3 THEN SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = errorMessage; END IF; END $$ UPDATE sales SET quantity = 150 WHERE id = 1; UPDATE sales SET quantity = 500 WHERE id = 1;