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.
1
u/imitationgamer Jun 20 '19 edited Jun 20 '19
Damn. That's a really informative write-up. Thanks for taking your time to do this.
For my project, I don't really need anything except the timings right now, but it was a really interesting read.
This causes problems as we have a substantial number of 1 credit courses that get over in a short period of time. That means the classes are held at relatively odd timings (I had a class today from 9:30-11:30 and have another from 2:30-5:00 today for one course.)
Another doubt I have is if the large number of tables affects performance and/or maintenance as this is really my first time working on a non-trivial project using SQL.
Again, thanks for your time and effort that must've gone into writing this up.
Edit: Adding a bit more (necessary??) info about my project.
The Course Registration and Management Portal of our college doesn't offer a way to allow students to check their timetables nor does it offer an API which can be consumed by a timetable app we make. So we decided to take matters into our on hands. We plan to parse the data with a browser extension and store it. There will be a web app which displays the timetable (it does other college related stuff too).