In this article, Naeem shows us how to go about creating a statistical view of data, in the form of a clustered bar chart, using PHP and MySQL. He provides a real-life scenario, along with accompanying code, to demonstrate how the job can be accomplished.
Statistical View of Data in a Clustered Bar Chart - Database (Page 2 of 5 )
The database consists of four tables.
Students
Programs
Subjects
Marks
Each of the first three tables has a one-to-many relationship with the Marks table.
SQL statements to create these tables are as follows:
Marks Table
CREATE TABLE marks ( id int(11) NOT NULL auto_increment, student_id int(11) DEFAULT '0' NOT NULL, program int(11) DEFAULT '0' NOT NULL, subject int(11) DEFAULT '0' NOT NULL, marks int(11) DEFAULT '0' NOT NULL, entry_date date, PRIMARY KEY (id) );
Programs Table
CREATE TABLE programs ( id int(11) NOT NULL auto_increment, program varchar(255), PRIMARY KEY (id), UNIQUE program (program) );
Students Table
CREATE TABLE students ( id int(11) NOT NULL auto_increment, name varchar(100), PRIMARY KEY (id) );
Subjects Table
CREATE TABLE subjects ( id int(11) NOT NULL auto_increment, subject varchar(255), PRIMARY KEY (id), UNIQUE subject (subject) );