i have a timetable application and i'm stuck at a point. now while allotting a slot to a teacher i need to display only those rooms which are vacant based on certain conditions i.e. the day and period coordinates(x,y) and the semesters which means the even semesters (2,4,6) cannot have classes in that room at same time and same is for the odd semesters(1,3,5).
my table structure:
Room table
roomid, roomname
papers table
id, semster, papername
ttresponsibility table(this is the one where we store the allocations)
id, teacherid, day, period, subjectid, room
Now my requirement is to fetch only those rooms at the time of allocation which are vacant. this ofcourse should be while selecting for a teacher and the course, semester and the paper has been selected. my idea is to populate the rooms dropdown on the onchange event of paper dropdown. Please correct me if i'm wrong.
Something like this might get there:
SELECT roomname
FROM Room
WHERE roomid NOT IN
(
SELECT roomid
FROM ttresponsibility
WHERE period = *insert_timeperiod_to_search_for_empty_rooms_here*
AND day = *insert_day_to_search_for_empty_rooms_here*
)