 
 DELIMITER ;
 
-
-
-/*Sous tâche : Une tâche qui a déjà une tâche parente ne peut pas avoir de sous-tâche. Autrement dit, on s’arrête à un seul niveau de sous-tâche.*/
+USE easygoing;
+DROP TRIGGER IF EXISTS tasksBeforeInsert
+
+DELIMITER $$
+USE easygoing $$
+
+CREATE TRIGGER tasksBeforeInsert
+BEFORE INSERT ON tasks
+FOR EACH ROW
+BEGIN
+
+	IF taskHasParent(NEW.parent_task) THEN
+		SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = "The parent_task has a parent.";
+	END IF;
+	
+END $$
+
+DELIMITER ;
+USE easygoing;
+DROP TRIGGER IF EXISTS tasksBeforeUpdate
+
+DELIMITER $$
+USE easygoing $$
+
+CREATE TRIGGER tasksBeforeUpdate
+BEFORE UPDATE ON tasks
+FOR EACH ROW
+BEGIN
+
+	IF taskHasParent(NEW.parent_task) THEN
+		SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = "The parent_task has a parent.";
+	END IF;
+	
+END $$
+
+DELIMITER ;
+
+
+
 
 
 /* Insert some data */

END $$
DELIMITER ;


/* TRIGGERS */
USE easygoing;

END $$
DELIMITER;

/* This function check if a user can produce in a task */
USE easygoing;

DELIMITER $$
