title: SQL using trigger for constraint
body: <p>I am studying triggers and constraints.</p>
  
  <p>And I got a question to use trigger (To be honest, I am not really sure how to use trigger..)</p>
  
  <p>Let's say we have a Teachers table.</p>
  
  <p>And this teacher table contains teacher_id , ssn , first_name , last_name , class_time</p>
  
  <p>for example, </p>
  
  <pre><code>|teacher_id|ssn    | first_name | last_name | student_number| max_student
  |1         |1234   | bob        | Smith     | 25            |25
  |2         |1235   | kim        | Johnson   | 24            |21
  |3         |1236   | kally      | Jones     | 23            |22
  </code></pre>
  
  <p>and </p>
  
  <p>let's say the max number of student number will be 25.(max number of student will be defined by teacher, so it can be any number like 10, 22 , 25...)</p>
  
  <p>and a student wants to add the bob's class. However, I want to make the trigger that rejecting to add the student.(because bob's class is already full..)</p>
  
  <p>However, I am not really sure the way to create the trigger .. :( .. (this is the first time to study about  trigger.... )</p>
  
  <p>Can anyone help to create the sample code to understand trigger part?</p>