QCode

From LBwiki

Design & code structure for the Questionaire

Tables questionaire

CREATE TABLE `questionaire` (
 `qid` int(10) unsigned NOT NULL auto_increment,
 `question` text NOT NULL,
 PRIMARY KEY  (`qid`)
) TYPE=MyISAM COMMENT='questions table' AUTO_INCREMENT=11 ;


qdetails - details of institute & person taking survey

CREATE TABLE `qdetails` (
 `pid` int(11) NOT NULL auto_increment,
 `pname` varchar(128) NOT NULL default ,
 `pemail` varchar(128) NOT NULL default ,
 `cname` varchar(255) NOT NULL default ,
 `caddr` varchar(255) NOT NULL default ,
 `cweb` varchar(255) NOT NULL default ,
 `cemail` varchar(255) NOT NULL default ,
 PRIMARY KEY  (`pid`)
) TYPE=MyISAM COMMENT='table for surveyee details' AUTO_INCREMENT=1 ;

answers - table to store answers, the 5 multiple choices will be represented as options 1-5

CREATE TABLE `answers` (
 `aid` int(11) NOT NULL auto_increment,
 `qid` int(11) NOT NULL default '0',
 `pid` int(11) NOT NULL default '0',
 `q1` int(11) NOT NULL default '0',
 `q2` int(11) NOT NULL default '0',
 `q3` int(11) NOT NULL default '0',
 `q4` int(11) NOT NULL default '0',
 `q5` int(11) NOT NULL default '0',
 `q6` int(11) NOT NULL default '0',
 `q7` int(11) NOT NULL default '0',
 `q8` int(11) NOT NULL default '0',
 `q9` int(11) NOT NULL default '0',
 `q10` int(11) NOT NULL default '0',
 PRIMARY KEY  (`aid`)
) TYPE=MyISAM AUTO_INCREMENT=1 ;

tables done now some insert code

someones just filled up the details!

INSERT INTO `qdetails` ( `pid` , `pname` , `pemail` , `cname` , `caddr` , `cweb` , `cemail` )
VALUES (
, 'Good Name', 'myemail@domain.com', 'Best Institute of Technology', 'Street 420, Airway, LostCity,  ForgottenNation', 'http://www.google.com', 'bestit@bestitdomain.com'
);

& the answers


INSERT INTO `answers` ( `aid` , `qid` , `pid` , `q1` , `q2` , `q3` , `q4` , `q5` , `q6` , `q7` , `q8` , `q9` ,  `q10` )
VALUES (

, '1 ', '1', '1', '2', '3', '4', '5', '5', '4', '3', '2', '1'

);
Personal tools
-->