Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Grade class with Threshold table #6

Open
scd31 opened this issue Jan 23, 2020 · 0 comments
Open

Replace Grade class with Threshold table #6

scd31 opened this issue Jan 23, 2020 · 0 comments

Comments

@scd31
Copy link
Contributor

scd31 commented Jan 23, 2020

We can create a Threshold table in the database that has a n:1 relationship with the Course table. This makes the code cleaner and DRYer. It also makes it possible to add courses with more or less letter grades than the ones specified in the code.

My proposal would be for the Threshold table to have the following attributes: (id: int, name: varchar, threshold: double, course_id: int, grade: double). Most of these are self explanatory, but the grade column is for the number that gets used to calculate GPA.

The following SQL could be used for a lookup:
SELECT grade FROM Threshold WHERE course_id = ? AND threshold <= ? ORDER BY grade DESC LIMIT 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant