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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started