Question: This needs to be done in SQL Server (Murach's book) and it is continuing question on previously answered question; Create a database trigger RENTALS_RENT that

This needs to be done in SQL Server (Murach's book) and it is continuing question on previously answered question;

Create a database trigger RENTALS_RENT that should fire every time a record is inserted into the Rentals table. It should increment the outstanding column for the appropriate Movies record in the Movies table.

Add at least 3 records into the Rentals table (use any numbers for the rid column) and prove that the outstanding column in the Movies table was updated correctly. Enclose the insertions in a transaction. Make sure to commit.

Submit the statements used to create the trigger, the statements used to insert the Rentals records and a query that proves the Movies table was updated properly.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

(This is a table created in previous question:

Table Creation queries:-

create table Movies(mid int primary key,title varchar(20),outstanding int default 0);

create table Rentals(rid int primary key,mid int,rental_date date,returndate date,foreign key(mid) references Movies(mid));

Inserting values to the Movies Table:-

insert into Movies values (101,'Pokiri',10);

insert into Movies values (111,'Spyder',50);

insert into Movies values (222,'Awe',23);

)

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!