mysql store procedure for complex schedule creation