I am relatively new to programming so be gentle...
I am trying to develop a page to display student/class results by subject/teacher.
Some classes have groups which contain students and some have only students. A subject is thought by one or more teachers. This may change in the future and I want to keep the design as flexible as possible (i.e. subjects might be broken into modules or into individual test results, classes might be further grouped by year etc)
I want to display the end results in a grid that I can expand and roll up to average out the results (class on the Y and subject on the X).
My though it to have 3 database tables as follows:
**class_structure**
id (int) PK
description (varchar)
parent_id (int) FK to id
The highest level would be the class (with no parent id) and the lowest level would be the student.
**subject_structure**
id (int) PK
description (varchar)
parent_id (int) FK to id
The highest level being the subject, lowest being the teacher
**results**
id (int) PK
class_structure_id (int) FK
subject_structure_id (int) FK
date (datetime)
reult (int)
What do you think of the above structure? I believe this gives me flexibility going forward?
In my asp.net app then I query the highest class structure level and average out all the results below that (am I better to do this averaging in a sproc in the DB or use say LINQ in the app?)
This would give me back a set of results at the highest level.
Then I would need to display this is a table (i am thinking of just creating the table html in C#?) against the subject classes (i.e. create all the headers first and then try to place the result in the correct column (i am not sure how to do this though)).
<table border="1" padding="2">
<tr>
<td></td>
<td></td>
<td colspan="2" align="center">Subj 1</td>
<td colspan="2" align="center">Subj 2</td>
</tr>
<tr>
<td></td>
<td></td>
<td>Teacher 1</td>
<td>Teacher 2</td>
<td>Teacher 1</td>
<td>Teacher 2</td>
</tr>
<tr>
<td rowspan="2">Class 1</td>
<td>Student 1</td>
<td>90</td>
<td>55</td>
<td>75</td>
<td>100</td>
</tr>
<tr>
<td>Student 2</td>
<td>40</td>
<td>95</td>
<td>65</td>
<td>39</td>
</tr>
</table>
Then when the user clicked on the first class, this would expand out and show all the groups (if any, students if not) (pass the class_structure_id of the clicked cell to the same method/sproc and get those results) and then redraw the table with an extra column.
Is this a good way to go about achieving what I am trying to do?
Thanks for your time.