r/SQL • u/imitationgamer • Jun 19 '19
PostgreSQL Store student timetables in PostgreSQL
For a project I'm working on, I need to store the course timetables of the students in my college in a PostgreSQL database (this is not my decision).
Some Background:
- College has around 3000 students and due to the freedom in course selection, we might as well as assume each student might have a unique course list.
- We have names for certain slots (let's say for example, Weekdays 9AM-10AM is slot A). Most courses follow these slots, but others have custom timings with classes of variable lengths of time.
- While it is uncommon, some courses have two classes on the same day. By class, I mean a single continuous chunk of time a student has to be present in the classroom.
- I will also have to store the course's start and end dates.
My ideas:
A table for the schedule of all courses and tables listing courses for each student.
- One hack for storing the course schedule for a week was to split it into half an hour intervals and store a string with binary values of whether a class is there in that period.
- Another way of storing the course schedule was to have a Day Start Time and Day End Time for each day. To work around have multiple classes on the same day, have Day Start Time 1, etc.
I see both the methods as hacky and was hoping someone could suggest a schema (or give me hints/resources to learn making one my own). It would be really nice if it used the built-in types in the database instead of parsing through strings.
I'm new to working with a SQL database and relatively new to Development, so my apologies if I have missed anything. I'm also not sure if a support request such as this is allowed here, but I couldn't find anything describing a solution I can adapt elsewhere and do not know where else I can ask.
Thank you.
View all comments
Show parent comment
1
u/imitationgamer Jun 20 '19
For us each each Semester is broken into 3 Segments and there is an add/drop period for trying out courses. So I'm looking at generating the timetables at least six times a year and easily more than that. The only consolation is that I won't have to do it at the same time for all the students.
I'm guessing this will be something I'll have to find out by trial.
I'm not quite sure I understand how this stores the multiple classes per day for a course, possibly due to the different terminology. I would be grateful if you could explain it further.
Again thanks for your time; this has been illuminating. :)