Skip to content

Database Models

Leon Ming edited this page Mar 1, 2021 · 3 revisions

Database Models

This documentation describes the database models in the Catalog app.

NoSleep

Course

A course represents a single class at Berkeley, independent of the semester or year it is offered. The table contains information about the title, description, units, etc about the course. It is uniquely identified by the abbreviation and course_number.

Course data can be updated every once in a while to match information in SIS. To understand how to do this, please refer to:

Section

A section represents a particular section for a semester and year. For instance, COMPSCI 61A LEC 1 @ Fall 2013 and COMPSCI 61A LAB 003 @ Spring 2015 are both Sections. The Berkeleytime DB currently stores about ~53,000 sections from the last 3-4 years. A section contains information about its location, start time, end time, etc. A Course can have many Sections. A Section is also tied to a campus.Room.

Enrollment

An enrollment represents a single data-point about class-size for a single section. Information about how many people were on October 1st for COMPSCI 61A LEC 1 @ Fall 2012 would represent a single row in the Enrollment table. There are currently ~6,000,000 Enrollment entries in our database.

Grade

A grade represents a histogram of grade distribution tied to a implicitly tied to a single section (but technically ForeignKey'ed with Course). The grade distribution for John Denero's COMPSCI 61A LEC 1 @ Fall 2012 is represented in a single grade entry. To update grades see New Grades.

Playlist

Berkeleytime's best feature is the ability to filter through courses by requirement, time-of-day, average grade, etc. This is internally called Playlist. A playlist has a Many-to-Many relation with courses. It is simply a collection of courses, which is calculated which is partially updated every-time we call catalog/sync.py:sync_all_sections. There are two types of playlists.

  1. Generalized Playlists: Playlists containing which courses satisfies requirement information (e.g. American Cultures) are available to everyone, and do not have an associated user foreign-key and category="custom"

  2. Favorites: These playlists are specific to a user. It contains all the courses favorited by that user, and are not shown to anyone else.

How do we update what courses are in a playlist?

  1. Generalized Playlists: A list of these filters are in catalog/default_filters.py. Every night, when we update section information, we update a certain subset of non-custom Playlists that are temporal. These are playlists/filters that involve things dependent on time-of-day, enrollment information, that are subject to change based on the new Schedule information. This logic is located in catalog/sync.py/sync_temporal_playlists.

Every once in a while, you may also need to call catalog/sync/sync_all_playlists, which updates playlists for requirements (e.g. American Cultures). Don't worry, this only matches against the Django Course model and doesn't go out to Berkeley's broken end-points.

  1. Favorites: User generated playlists are updated by specific users through our favoriting system. Users automatically get their own favorite playlist on account creation.
Clone this wiki locally