title: Database structure for storing schedules/cron job?
body: <p>I am stuck with a problem. In an app's db, I am having a <code>schedule</code> table  which will store user provided schedules. E.g</p>
  
  <ul>
  <li>Daily</li>
  <li>Every Week </li>
  <li>Twice a Week</li>
  <li>Every 3rd (or any user chosen) day of week</li>
  <li>Every Month</li>
  <li>Twice a month</li>
  <li>Every x day of month</li>
  <li>Every x month of year</li>
  </ul>
  
  <p>And so on. These schedules will then provide reference point to schedule different tasks or identify their repeat-ance. </p>
  
  <p>I am not able to think of a proper database structure for it. The best I can get is to have a table with following columns:</p>
  
  <ul>
  <li>Day</li>
  <li>Week</li>
  <li>Month</li>
  <li>Year</li>
  <li>type</li>
  </ul>
  
  <p>Then store the specified schedule in the related column and provide the type. 
  e.g Every week can go like 1 in week column and 1 (designated value for repeating whole) or something like that. </p>
  
  <p>The problem with this approach is that this table is gonna be used very frequently and the data retrieved will not be straightforward. It will need calculation to know the schedule type and hence will require complex db queries to get each type of schedule. </p>
  
  <p>I am implementing it in Laravel app if that can provide any other methodology. It's a SAAS app with huge amount of data related to the schedule table. </p>
  
  <p>Any help will be very much appreciated. Thanks</p>