Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Step: 3

blur-text-image

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

Data Management Databases And Organizations

Authors: Richard T. Watson

2nd Edition

0471180742, 978-0471180746

More Books

Students also viewed these Databases questions

Question

Were the decisions based on appropriate facts?

Answered: 1 week ago

Question

Were the right people involved in the decision-making process?

Answered: 1 week ago