Question: This lab provides you the opportunity to implement triggers with the use of SQL.commands. The lab wil utilize the FLIX2YOU problem, the curment schema inorder

 This lab provides you the opportunity to implement triggers with the

This lab provides you the opportunity to implement triggers with the use of SQL.commands. The lab wil utilize the FLIX2YOU problem, the curment schema inorder to start this lab, you must have successtuly completed Lab #6 and 7. In these labs, you created FLIXZYOU tables and populated data into the tables in your folder in SOL Server in the VLABS environment Lab #8 requres you to make a modication to the database structure. create triggers, and then best the triggers. You will need to run the script in your own personal A TRIGGERS when executed must be free oe errors and warnres. COMMANDS FOR TRIGGERS in SOL Server: DROP TRIGGER trigger name CREATE TRIGGER trigger name On table name FOR event name AS BEGIN Commands END NOTE: The textbook (chapter 8) provides examples of triggers to be used in an Oracle database server. The OLD and NEW atributes as provided in the textbook does not apply to SOL Server For SOL Server, if you are refeming to the old data... you will access a temporary table called DELETED. If you are relerring to the new data.. you will access a temporary table called INSERTED Example: SOL code for SQL Server to create a trigger to update CREATE TRIGGER tr.order value update ON Orderline FOR UPDATE AS BEGIN UPDATE orders SET order value oeder value SELECT qty from DELETED) (SELECT unitprice FROM DELETED ISELECT qty FROM INSERTED) (SELECT unitprice FRIOM INSERTED WHERE orders.ordemo (SELECT ordemo from INSERTED) END A new requirement has been ideitied for the FLIXZYOU database. Inventory personnel at FLIXZYOU frequently need data on how many times a partioular movie has been rental. There is a move within FLIX2YOU to retain the privacy of all customers and has been mandated that inventory personnel cannot have access to customer information including rental transaction data. So, the soludion is to add accumulative data to the movie table. This is done by including a field in the MOVIES table that will contain a value representing the number of times a movie has been rented. A trigger will be created to update the value in MOVIES each time a customer rental recond has been added, deleted or updated Write and execute the proper SOL commands to add a ield (name:num movies datatype: int) to the ACTORS table. You will also need to innalize the field value to zero for all existing records in the ACTORS table (SeethewasehoollRage), for help with adding a field to an existing table PART 2 Create three triggers for each of the events.. INSERT, UPDATE, DELETE. The trigger will either add, subtract or addisubtract the occurrence of the event PART 3 Write and execute SOL commands to test the three events. You need to show the value of num rentals with a SELECT statement befone the event and then afher the event Attach a document to the drop box for this lab that contains the copylpasted SOL commands that you executed AND ALL the messages returned trom SOL Server from the execution of the commands. Be sure to title each section of your document with the appropnate PART that PART 2 and PART

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!