250 ◾ Cloud Database Development and Management
7.4.2 Using Triggers
Now, we will discuss how triggers are used in database management and business logic imple-
mentation through examples. Triggers will be used to enforce business constraints and implement
application logic dynamically to keep database integrity.
7.4.2.1 Validating Business Constraints
Here, we will use a trigger to verify if a student has met the prerequisite requirement before he/she
enrolls in a new class. Before a student and class information can be added to the table STUDENT_
CLASS, an AFTER trigger is used to query the courses that have been taken by the student and
then compare the prerequisite of the course to be taken. If there is a match, add the student and
class ...