Question: Write the following as triggers. In each case, disallow or undo the modification if it does not satisfy the stated constraint. You also need to

Write the following as triggers. In each case, disallow or undo theWrite the following as triggers. In each case, disallow or undo the modification if it does not satisfy the stated constraint. You also need to test those triggers by writing MYSQL queries that might fire those triggers and then check the database to make sure that triggers were called correctly. Include these test queries in your submission. Indeed, for each question we need to have ~ two SQL queries; one that satisfy the condition that execute the trigger and another one that doesnt satisfy the trigger condition and hence the trigger will not be executed. 1. Write a trigger called Course_prerequisite when student tries to enroll in new course, check that he/she already took the prerequisite course. If not reject the insert to the relation takes. For example, if students try to enroll in course CS-190 they should have completed the prerequisite course CS-101 successfully (i.e. grade should not be F or null). Write MYSQL statement(s) that will fire this trigger. 2. Write a trigger called credits_earned to keep total credit attribute in student tables up to date. The trigger is executed when the grade attribute is updated from a value that is NULL or F to a grade that indicates the course is successfully completed. Write MYSQL statement(s) that will fire this trigger. 3. Write a trigger called New_Dept to add new department name to the department relation if we attempt to insert an instructor into a department whose name does not appear in the department relation. Write MYSQL statement(s) that will fire this trigger. [HINT: to avoid foreign-key violation you could insert a tuple in the department relation for that department name before the insertion to instructor relation]

The figure below shows the database schema for University database

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!