Example: representation of a timetable

previous  Top  next

Example: representation of a timetable


Preparation: create a table 'lesson' to accommodate the lesson structure and import the lesson data into the table.


create table lesson


 teacher char(20),

 day        tinyint,

 period        tinyint,

 subject        char(20),

 room        char(20),

 lessonid        int,

 flag        int,

 class        char(20),

 week        char(53)



If for example a timetable for teacher New for week 37 is to be displayed, you can issue the following SQL statement to find the data records required:


Select * from lesson where teacher = ‘New’ and not (mid(week, 37, 1) = ‘0’);




The required data for every possible period (i.e. periods 1 through 8 from Monday to Friday) can now be found in the result of the database query.


The week flag for the 37th week indicates whether lessons take place or whether they are not applicable. If the timetable is to be represented without any particular flag indicating whether lessons apply or not, the data records can be ignored when week flag = x.