Note that there are some explanatory texts on larger screens.

plurals
  1. POCreating columns of a table using the rows of another
    primarykey
    data
    text
    <p>I'm working on my project in php [handling students attendance system]. I have a list of students along with their unique id[<code>jntuno</code>] 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 :</p> <p>I have a table <code>students</code> in mysql with the following fields and data in it :</p> <p><img src="https://i.stack.imgur.com/UCrjV.jpg" alt="my table contents"></p> <p>now I want to create a new table with the each of the values in the <code>jntuno</code> field as a columns of my new table.</p> <p>I want my new table [let us name it <code>attendance</code>] to have columns like this :</p> <pre><code>+------------+-----------+----------+-----------+-----------+ |11341A0501 |11341A0502 |11341A0503|11341A0504 |11341A0505 |...... +------------+-----------+----------+-----------+-----------+ | | | | | | </code></pre> <p><strong>How to do this in mysql ?</strong></p> <p>I will later add 3 fields to the <code>attendance</code> table namely :</p> <p>-> <code>date</code>[the date on which a particular subject is taught] , </p> <p>-><code>subject</code>[the name of the subject taught] and </p> <p>-><code>hours taught</code>[the number of hours for which a particular subject is taught(can be 1 or 2 or 3 ... upto 6)] </p> <p>every <code>subject</code> taught on a particular <code>date</code> will be adding a new <code>row</code> to the <code>attendance</code> table </p> <p><strong>Example:</strong></p> <pre><code>+------------+-----------+-----------------+------------+-----------+----------+-----------+-----------+ |date |subject | classes taught |11341A0501 |11341A0502 |11341A0503|11341A0504 |11341A0505 |.. +------------+-----------+-----------------+------------+-----------+----------+-----------+-----------+ |2013-09-31 |OOPS |3 |2 |3 |0 |1 |3 | </code></pre> <p>I choose the tables in this way so that the entry of attendance into the table would be more faster. </p> <p>But many call this a <strong>BAD DATABASE STRUCTURE</strong> . So please suggest me if there's some other good and efficient database design for my problem</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload