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
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;
|
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;
|
Friday, December 16, 2011
i have just started the blog today. so many things will follow on posting and also you will be updated with so many stories that happened around grobal. stay tuned
Subscribe to:
Posts
(Atom)
Followers
About Me
- the edwards
- 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
Blog Archive
Logo
Facebook Badge
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.