Question: 1 . Task One: Logging New Purchases Create a trigger that logs every new book purchase ( insert ) into the Transactions table with the
Task One:
Logging New Purchases
Create a trigger that logs every new book purchase insert into the Transactions table with
the action 'Purchase'.
Is this a RowLevel Trigger or StatementLevel Trigger?
SQLMySQL Code:
Run the following Execution Code:
Execution
INSERT INTO Transactions bookid action
VALUES 'Purchase';
Screenshot showing execution:
Task Two:
Preventing Discount Abuse
Create a trigger that prevents purchases of books priced below $ if the stock quantity is
less than
Hint: Use a BEFORE INSERT trigger to raise an error.
Is this a RowLevel Trigger or StatementLevel Trigger?
SQLMySQL Code:
Run the following Execution Code:
Execution
INSERT INTO Transactions bookid action
VALUES 'Purchase';
Screenshot showing execution:
Task Three:
Author Discounts
Create a trigger to apply a discount if the author's name contains "John" when a new
book is inserted.
Is this a RowLevel Trigger or StatementLevel Trigger?
SQLMySQL Code:
Run the following Execution Code:
Execution
INSERT INTO Books title author, price, quantity
VALUES Advanced SQL 'John Doe', ;
Screenshot showing execution:
Challenge Tasks:
Challenge Task One:
Checking Inventory
Create a trigger to prevent reducing stock quantity below during an update to the
Books table.
Is this a RowLevel Trigger or StatementLevel Trigger?
SQLMySQL Code:
Run the following Execution Code:
Execution
UPDATE Books SET quantity WHERE bookid ;
Screenshot showing execution:
Challenge Task Two:
Logging Bulk Deletions
Create a statementlevel trigger to log a message in the Transactions table if more than
books are deleted in a single operation.
Is this a RowLevel Trigger or StatementLevel Trigger?
SQLMySQL Code:
Run the following Execution Code:
Execution
DELETE FROM Books WHERE price ;
Screenshot showing execution:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
