June 5, 2023

Replicate the functionality of ‘on delete cascade’ and ‘on update cascade’ using triggers on movies and rentals tables

Note:Both Movies Rentals table don’t have primary foreign keys. Use only trigger to implement above.

Movie Tables

ID   Title                      Category
1   ASSASSIN'S CREED EMBERS     Animations
2   Real Steel                  Animations
3   Alvin   Chipmunks           Animations
4    Adventures of Tin Tin      Animations
5   Safe                        Action
6   Safe House                  Action
7   GIA                         18
8   Deadline 2009               18
9    Dirty Picture              18
10  Marley  me                  Romance

Rentals tables

memid First_name  Last_name  Movieid
1     Alicia      Alarcon     1
2     Don         Draper      2
3     Lizzie      Moss        5
4     Eldon       Chance      8
5     Jenny       Patterson   10
6     Craig       Daniels     Null
7     Denny       Pattinson   Null

Since I am a beginner in SQL, therefore, I couldn’t form a proper query. T tried till this much.

Create trigger 'movren_trg'
After Update on 'Movies' and 'Rentals'
For each row