73.5k views
2 votes
Create a trigger that prevents anychange(insert, update, or delete)to the grade attribute of the takesrelation that would change the total credits of the corresponding student by more than 10 credits. For example, if thecurrent total credits of Sanchez are38, then any change that makes histotal credits greater than 48 or less than 28 would be prevented.b)(10points)Test thetrigger with three distinct events: one insert, one update, and one delete

User Sabanito
by
6.3k points

1 Answer

1 vote

Answer:

The trigger code is given below

create trigger F1_Del

after delete on Friend

for each row

when exists (select * from Friend

where ID1 = Old.ID2 and ID2 = Old.ID1)

begin

delete from Friend

where (ID1 = Old.ID2 and ID2 = Old.ID1);

end

create trigger F1_Insert

after insert on Friend

for each row

when not exists (select * from Friend

where ID1 = New.ID2 and ID2 = New.ID1)

begin

insert into Friend values (New.ID2, New.ID1);

end

User Georg Heiler
by
5.9k points