Remember your old school. How time table is prepared?
Write a robust SQL query after defining necessary tables with enough dynamism and flexibility.
Guys please help to sort it out
Following are the hints:
- Subject master
Subject ID | Subject Name |
S1 | Malayalam |
S2 | English |
S3 | Hindi |
S4 | Science |
S5 | Social Studies |
S6 | Mathematics |
S7 | Drawing |
- Employee master (Teachers master)
Teacher ID | Teacher Name | Maximum number of periods to be taken in a week |
T1 | Sreekumar | 15 |
T2 | Prajesh | 15 |
T3 | Madhu | 15 |
T4 | Benoy | 15 |
T5 | Binu | 15 |
T6 | Nishanth | 15 |
- Teacher capabilities master (linking teacher to a subject)
Subject Name | Teacher Name |
Malayalam | Sreekumar |
English | Prajesh |
Hindi | Binu |
Science | Nishanth |
Social Studies | Benoy |
Mathematics | Prajesh |
Drawing | Madhu |
- Classes and divisions master (requirement)
Class ID | Division ID |
5 | A |
6 | A |
6 | B |
7 | A |
7 | B |
7 | C |
Given below are the logical points to be considered;
- 7 periods in a day, 5 days a week.
- One teacher cannot be present two classes at the same time and two teachers should not come in a class.
- All class must have a teacher.
- Maximum classes per week for a teacher as per teacher master.
- Teachers missing in a class not allowed.
- Not more than two continuous slots should be allocated for a particular subject in a day.
- Enough leisure period need to be planned for teachers.
- Keep same pattern of subject’s every-day to the best possible level (Eg. Class teacher will take first period every day)
Output
(Time table for 6A) Hint: need to present liner records only, no pivot reqd.
Day | Period | ClassID | DivisionID | SubjectID | TeacherID |
Monday | I | 6 | A | S1
| T1 |
Monday | II | 6 | A | S3 | T5 |
Monday | III | 6 | A | S5 | T4 |
Monday | IV | 6 | A | S2 | T2 |
Monday | V | 6 | A | S4 | T6 |
Monday | VI | 6 | A | S6 | T2 |
Monday | VII | 6 | A | S7 | T3 |
Tuesday | I | 6 | A | S1
| T1 |
|
|
|
|
|
|
|
|
|
|
|
|