I am working for a K-12 school and I am developing a gradebook system. The existing gradebook system that we use which I also developed is based on Excel with VBA. It’s always a nightmare for me to consolidate 400+ Excel workbooks every end of term. During the summer break, I’m planning to put all data in a database for easy management and stuff.
My problem is this:
For a computation-intensive application like a gradebook, is it good to store the computations in a table field or is it better to ONLY store the raw data and do the computations only on the frontend?
The way the Excel gradebook system works is like this…
- Teacher records each score for each assessment of each student in the form of score / highest possible score. (e.g. Quiz 1 = 5/10, Homework 1 = 20/25, etc.)
- The scores will be calculated as percentages and summarized per component. “Component” means Quiz, Homework, etc. So there will be something like “Quizzes Average = 90%, Homework Average = 80%, etc.“
- Different subjects will have different final grade breakdown like “Science = 50% Quizzes + 50% Homeworks, Math = 60% Quizzes + 40% Homeworks“.
- Then, the general average grade of each student is computed by getting the average of all subjects.
Everything above is very easy to make in a spreadsheet but I don’t know how to implement it in a database.
As of the moment, I’m thinking something like having a table where all assessments are recorded like this:
tbl_scores
id
student_id
term_id
subject_id
component_id
assessment_id
raw_score
highest_possible_score #not sure about this cause this can be implied from assessment_id
Would it be useful to store the computations (percentage for each score entry, component average, subject average, general average, etc. in the database) and use stored procedures and triggers to update them when a new score comes in?
Or, is it better to just store the raw scores and calculate everything ONLY on the frontend? Will this option be faster than the first one knowing that the SELECT queries here will really be more complex due to subqueries?
By the way, I’m planning to use PostgreSQL for this.
Thanks in advance for any advice.
DashMug
400 students, that is peanuts for an RDBMS that is designed to handle millions of records. You need not worry about performance.
I have seen nothing in your description that PostgreSQL could not do in simple queries. Store only the necessary information and calculate the rest. Also, do not add a redundant column
highest_possible_scoreto your tabletbl_scoresif that information is in the linked tableassessmentalready. That would do more harm than good.If (and only if) you should later find that a query is too slow, you can always use materialized views (write the output of a query to a table, recalculate that table after changes to the base data.)