title: electronic leave application database design
body: <p>I am currently working on a leave application (which is a subset of my e-scheduler project) and I have my database design as follows:</p>
  
  <pre><code>event (event_id, dtstart, dtend... *follows icalendar standard*)
  
  event_leave (event_id*, leave_type_id*, total_days)
  
  _leave_type (leave_type_id, name, max_carry_forward)
  
  _leave_allocation (leave_allocation_id, leave_type_id*, name, user_group_id, total_days, year)
  
  _leave_carry_forward(leave_carry_forward_id, leave_type_id*, user_id, year)
  </code></pre>
  
  <p>Does anyone here in stackoverflow also working on an e-leave app? mind to share your database design as I am looking for a better design than mine. The problem with my current design only occurs at the beginning of the year when the system is calculating the number of days that can be carried forward. </p>
  
  <p>In total I would have to run 1 + {$number_of users} * 2 queries (the first one to find out the number of allocation rules and the maximum carry forward quota. Then for each user, I need to find out the balance, and then to insert the balance to the database)</p>