Apologies in advance as I am new to triggers - I need to write a trigger to restrict a tutor from tutoring students from 5 different locations:
<code>TutorName StudentName LocationID ---------------------------------- Tom Harry 1 Tom Lima 1 Tom Liam 2 Tom Greg 3 Tom Bill 3 Tom Bob 3 Tom Lare 4 Tom Phill 4 Tom Hassan 5 Tom Nichole 5 Tom Levi 5
Tutor Tom can tutor a maximum of 5 groups of students from 5 different locations.
I need a trigger that will STOP Tom from teaching students from a different location as he is already teaching students from 5 locations EG: if he tries to teach someone from location 6 (East London) the trigger will stop this.
<code>LocationID Location Name ------------------------1 North East 2 North 3 South East 4 South West 5 West 6 East
not sure how to approach this as it seems very tricky - I can't do a simple count because the number of students can be anything up (1-5). Will I need an insert and update trigger? Please could someone help? :)