title: Database best normalization
body: <p>I have these tables in my database:</p>
  
  <pre><code>bookings(id,lessons_id,users_id)
  lessons(id,name,date,max_enrollments,enrollments)
  permits(id,user_id,used_entries,entries)
  </code></pre>
  
  <p>Everytime I insert a new record in bookings the</p>
  
  <pre><code>lessons.enrollments increments by +1 
  permits.used_entries -1 where user_id eq Auth()-&gt;id
  permits.entries increments by +1
  </code></pre>
  
  <p>I already have done three funx that do this in my PHP code but the prb is to do it in an automatic way! Can somebody give me some suggestions?</p>