I'm working on my project in php [handling students attendance system]. I have a list of students along with their unique id[jntuno
] and I need to create a database in mysql for storing the daily attendance of each student for each subject. So I created my tables in this way :
I have a table students
in mysql with the following fields and data in it :
now I want to create a new table with the each of the values in the jntuno
field as a columns of my new table.
I want my new table [let us name it attendance
] to have columns like this :
+------------+-----------+----------+-----------+-----------+
|11341A0501 |11341A0502 |11341A0503|11341A0504 |11341A0505 |......
+------------+-----------+----------+-----------+-----------+
| | | | | |
How to do this in mysql ?
I will later add 3 fields to the attendance
table namely :
-> date
[the date on which a particular subject is taught] ,
->subject
[the name of the subject taught] and
->hours taught
[the number of hours for which a particular subject is taught(can be 1 or 2 or 3 ... upto 6)]
every subject
taught on a particular date
will be adding a new row
to the attendance
table
Example:
+------------+-----------+-----------------+------------+-----------+----------+-----------+-----------+
|date |subject | classes taught |11341A0501 |11341A0502 |11341A0503|11341A0504 |11341A0505 |..
+------------+-----------+-----------------+------------+-----------+----------+-----------+-----------+
|2013-09-31 |OOPS |3 |2 |3 |0 |1 |3 |
I choose the tables in this way so that the entry of attendance into the table would be more faster.
But many call this a BAD DATABASE STRUCTURE . So please suggest me if there's some other good and efficient database design for my problem