SQL Movie-Rating View Modification Exercises Part B

SQL Movie-Rating View Modification Exercises Part B


Question 6
Write an instead-of trigger that enables deletions from view HighlyRated. 
Policy: Deletions from view HighlyRated should update all ratings for the corresponding movie that have stars > 3 so they have stars = 3.
 create trigger Q6
instead of delete on HighlyRated
for each row
begin
 update Rating
set stars = 3
  where mID = Old.mID and stars>3 ;
end;

Question 7
Write an instead-of trigger that enables insertions into view HighlyRated. 
create trigger Q7
instead of insert on HighlyRated
for each row
when New.mID in (Select mID from Movie where mID = new.mID and title =
New.title)
begin
  insert into Rating values (201, New.mID, 5, null);
end;
Question 8
Write an instead-of trigger that enables insertions into view NoRating. 
create trigger Q8
instead of insert on NoRating
for each row
when New.mID in (Select mID from Movie where mID = new.mID and title =
New.title)
begin
  delete from Rating where mID=New.mID;
end;
Question 9
Write an instead-of trigger that enables deletions from view NoRating. 
create trigger Q9
instead of delete on NoRating
for each row

begin
  delete from Movie where mID=Old.mID;
end;
Question 10
Write an instead-of trigger that enables deletions from view NoRating. 
create trigger Q10
instead of delete on NoRating
for each row

begin
  Insert into Rating Values (201,old.mID,1,null);
end;

Σχόλια

Ο χρήστης Uzma Khalid είπε…
Are u gonna upload screen shots of ur final exam.... plz do that. thank u
Ο χρήστης Krishna Nataraj είπε…
Plsssss upload the answers of the final exam asap.

a regular viewer of ur blog

Δημοφιλείς αναρτήσεις