Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribedWrite 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 23rd International Conference Dexa 2012 Vienna Austria September 2012 Proceedings Part 1 Lncs 7446

Authors: Stephen W. Liddle ,Klaus-Dieter Schewe ,A Min Tjoa ,Xiaofang Zhou

2012th Edition

3642325998, 978-3642325991

More Books

Students also viewed these Databases questions

Question

6. Identify seven types of hidden histories.

Answered: 1 week ago

Question

What is human nature?

Answered: 1 week ago