Mysql trigger

If you want to trigger an action to another table you can create a trigger:

CREATE TRIGGER `update_menus` AFTER INSERT ON `usuarios` FOR EACH ROW insert into sys_user_roles set sys_roles_id=(select sys_roles_id from sys_roles where roles_name=NEW.tipo),user_id=NEW.user_id

CREATE TRIGGER `update_totals_after_delete` AFTER DELETE ON `pedidos_detalle` 
FOR EACH ROW 
update pedidos set subtotal = (select sum(importe) from pedidos_detalle where folio=OLD.folio) 
where folio=OLD.folio

CREATE TRIGGER `update_totals_after_insert` AFTER INSERT ON `pedidos_detalle` 
FOR EACH ROW 
update pedidos set subtotal = (select sum(importe) from pedidos_detalle where folio=NEW.folio) 
where folio=NEW.folio