Thursday, December 29, 2011
SQL Movie-Rating View Modification Exercises[
-- Question 1
-- Write an instead-of trigger that enables updates to the title attribute of view LateRating.
-- Policy: Updates to attribute title in LateRating should update Movie.title for the corresponding movie. (You may assume attribute mID is a key for table Movie.) Make sure the mID attribute of view LateRating has not also been updated -- if it has been updated, don't make any changes. Don't worry about updates to stars or ratingDate.
-- 
-- Question 2
-- Write an instead-of trigger that enables updates to the stars attribute of view LateRating.
-- Policy: Updates to attribute stars in LateRating should update Rating.stars for the corresponding movie rating. (You may assume attributes [mID,ratingDate] together are a key for table Rating.) Make sure the mID and ratingDate attributes of view LateRating have not also been updated -- if either one has been updated, don't make any changes. Don't worry about updates to title.
-- 


Authorization Quiz

Question 1
The following SQL statement over tables R(c,d), S(f,g), and T(a,b) requires certain privileges to execute:
   UPDATE T
   SET a=1, b=2
   WHERE a <= ALL (SELECT d FROM R)
   OR EXISTS (SELECT * FROM S WHERE f > T.a)
Which of the following privileges is not useful for execution of this SQL statement?
UPDATE ON T
SELECT ON R(c)
SELECT ON T(a)
SELECT ON S

Question 2
Consider a set of users A, B, C, D, E. Suppose user A creates a table T and thus is the owner of T. Now suppose the following set of statements is executed in order:
  1. User A: grant update on T to B,C with grant option
  2. User B: grant update on T to D with grant option
  3. User C: grant update on T to D with grant option
  4. User D: grant update on T to E
  5. User A: revoke update on T from C cascade
Saturday, December 17, 2011
SQL Social-Network Triggers Exercises
Question 1
Write a trigger that makes new students named 'Friendly' automatically like everyone else in their grade. That is, after the trigger runs, we should have ('Friendly', A) in the Likes table for every other Highschooler A in the same grade as 'Friendly'.
create trigger R1
before insert on Highschooler
for each row
when  New.name="Friendly"
begin
  insert into Likes 
 Select New.ID,ID from Highschooler where grade = New.grade ;
 end;
Question 2
Write one or more triggers to manage the grade attribute of new Highschoolers. If the inserted tuple has a value less than 9 or greater than 12, change the value to NULL. On the other hand, if the inserted tuple has a null value for grade, change it to 9. 


create trigger R2
after insert on Highschooler
for each row
when  (New.grade is null)
begin
  update Highschooler set grade=9 where ID=New.ID;
end;
|

Followers

About Me

My photo
welcome to my blog! I'm Oswald Edward, a professional IT Specialist and entertainer. if you need to request a movie contact me with the email shown! Thanx

Contact Me

Email me at oedward38@gmail.com

Search

Follow Me

Subscribeto this blog
Follow me onTwitter
Connect onFacebook
Gallery onFlickr

Logo

Logo

Copyright


© 2013 by Oswald Edward.

You're welcome to link to this site or use a single image and brief description to link back to any post. Republishing posts in their entirety is prohibited without permission.