I have created a table (attendance_details
) for storing every day attendance of Students in MySQL. Need to capture attendance
for hourly (1-8hrs) every day. I have the student details in separate table (student_details
).
As of now, the fields I have created in attendance_details
are: attendance_no
(Foreign Key
which is Primary Key
in the student_details
table), date
, hour1
, hour2
, hour3
, hour4
, hour5
, hour6
, hour7
, hour8
.
A User
will only mark the absentees
, and the remaining students
should be marked as present
.
Is this a good design, since I want the report for each day attendance
based on hours of a all students
in a class
for every month? The Front-end is being developed C#
.
Also, I need to keep track of every hour attendance
.
Can you help me with the SELECT
query which should generate report as below?
MySQL Database fields are shown in the pic below:
Best Answer
It appears the OP is conflating how the data should be stored in the database with how the data will be displayed and/or entered when taking classroom attendance.
These are not necessarily the same thing. Display should not drive storage.
The UI could display the data the way the OP shows above in a classroom attendance form and have a middle layer that maps those values to and from more normalized tables in the database.
More work for the middle layer but more extensible and configurable when
An entry in an CLASS_ATTENDANCE table will have all the data that changes on a daily basis with foreign keys for the class, student, and status.
An entry in a CLASS table will have
An entry in a PERIOD table will have
Periods usually do not change during a single semester
There would like be a CLASS_STUDENT table that tracks which students are assigned to which class and drives filling in the CLASS_ATTENDANCE table daily.
This just one way to normalize the data. And there is still some redundancy between the CLASS_STUDENT table and the CLASS_ATTENDANCE table.