I want to design a DB for school, where marks for students will be scored. But i got stuck at a point with my current design where i want to insert student marks. My current DB design at broader level is something like:
------------------- ------------------- ------------------
STUDENTINFO | | EXAMS | | taught_in |
------------------- ------------------- ------------------
reg_id | | examID | | t_cisId |
cis_Id | | examname | | subjectcode |
$otherAttributes | | | | t_id(auto-inc)|
__________________| |_________________| |________________|
------------------- ----------------- ------------------
|ClassInSchool | | Subjects | |Result |
------------------- ----------------- ------------------
| classes | | subjectcode | | regId |
| section | | subjectname | | examID |
| cis_id | |_______________| | t_id |
|_________________| |__scoredmarks___|
Now Issue is : In result table i want only those records to be inserted in table for which following condition satisfies:
- A student should be a registered student (Satisfied by regId).
- Marks should be inserted for valid(existing) exam (satified by examId).
- A student who studies particular subject in a class, then marks should be inserted for those subjects only. This is where i am facing issue.
E.g, In sec A of class 7, English is taught. then For a student studying in 7A only marks for English can be inserted.
In my design if in sec B of 7 class, Maths is taught, then i can insert marks for a student for Maths
who is studying in 7 A
.
I want to handle this behaviour at database level only, otherwise i have to handle this in Java side.
Note: regId, examID, t_id are F.K. I have used similar names here for F.K to make it understand pictorially.