I’m working on this little enrollment system and i have this problem that if i want to enroll the student in my system the value of year/lvl should only increase, For example Grade1 once enrolled will be grade 2 and not decrease to preparatory nor double value to grade 3. So far my data entry is flat out inserting varchars. would appreciate any help on how can i do a pattern of progression and how should my database look like. Thanks.
Share
I wouldn’t suggest that you use varchars where you really mean numbers. It makes some things oh-so-much easier.
Now, with this structure, you have a table to identify your students nicely, you can do a lot with the primary key here as needed (link it to other tables, add functionality that you aren’t aware you want right now later – and the data is normalized). You have a neat table that defines what the student is enrolled in – linked back to the student. And lastly, you have another neat succinct table that holds subject information.
Looking at the
gradecolumn that is used to see where a student is at, you can use one of the following:When a student completes a course, you can update the grade like this:
The above will use a bound parameter from your application and the code will simply update the student grade to the subject that was just passed.
If you want students to be able to go back and do courses that have a lower grade, but don’t want their “grade” to to drop, you can easily modify the above to be this:
The update will now only modify a record where the student gained a “grade”.