I want to represent a timetable on a mysql database.
I had the idea that I should have three tables:
- a
classdetailstable – containing class capacity, classroom name, etc. - a
class_sessionstable with: start_time and end_time of session, - a
class_unittable with: the name of the course (MAT003. et.c)
there would also be appropriate foreign keys in the class_sessions table and class_unit table.
Eventually I want to be able to query for a ‘free’ class (one that does not have a class presently, at the time of running of the query) and return its name e.g (Room 5b)
Will the tables I have listed be sufficient for the query at hand?
Any ideas how to make this better will be appreciated.
This does what you said, but I’m still not 100% confident that what you said is what you want. 🙂
Having done that, one way to get the room number that’s not in use is with a query using SELECT…WHERE…NOT IN. This probably isn’t the fastest, but in my experience it’s the easiest syntax to understand.