1ALTER TABLE sales_details
2ADD FOREIGN KEY fk_product_code(product_code)
3REFERENCES products(product_code)
4ON DELETE CASCADE;
1 delimiter //
2 CREATE TRIGGER removeforeing
3 BEFORE DELETE ON products
4 FOR EACH ROW BEGIN
5 DELETE FROM sales_details WHERE product_code = OLD.product_code;
6 END//
7 delimiter ;
1delimiter //
2CREATE TRIGGER before_insert_money BEFORE INSERT ON money
3FOR EACH
4ROW
5BEGIN
6 UPDATE accounts SET balance=10.0;
7END;
8//
9delimiter ;