Code:
CREATE DATABASE IF NOT EXISTS tabulator;
USE tabulator;
--
-- Definition of table `subcriteria`
--
DROP TABLE IF EXISTS `subcriteria`;
CREATE TABLE `subcriteria` (
`id` double NOT NULL AUTO_INCREMENT,
`criteria` varchar(255) NOT NULL,
`percentage` tinyint(3) unsigned NOT NULL,
`awardid` double NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `subcriteria`
--
/*!40000 ALTER TABLE `subcriteria` DISABLE KEYS */;
INSERT INTO `subcriteria` (`criteria`,`percentage`,`awardid`) VALUES
('Poise and Grace',40,1),
('Figure and Beauty',20,1),
('Projection and Stage Presence',20,1),
('First Impression',10,1),
('Totality of Elements',10,1);
/*!40000 ALTER TABLE `subcriteria` ENABLE KEYS */;
--
-- Definition of table `tally`
--
DROP TABLE IF EXISTS `tally`;
CREATE TABLE `tally` (
`id` double NOT NULL AUTO_INCREMENT,
`score` tinyint(3) unsigned NOT NULL,
`contestantid` double NOT NULL,
`judgeid` double NOT NULL,
`criteriaid` double NOT NULL,
`competitionid` varchar(5) NOT NULL,
`categoryid` double NOT NULL,
PRIMARY KEY (`id`)
,FOREIGN KEY(categoryid)REFERENCES subcriteria(id) ON UPDATE CASCADE ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=48 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `tally`
--
/*!40000 ALTER TABLE `tally` DISABLE KEYS */;
INSERT INTO `tally` (`id`,`score`,`contestantid`,`judgeid`,`criteriaid`,`competitionid`,`categoryid`) VALUES
(43,88,1,1,1,'00001',(select id from subcriteria where criteria = 'Poise and Grace')),
(44,89,1,1,2,'00001',(select id from subcriteria where criteria = 'Figure and Beauty')),
(45,90,1,1,3,'00001',(select id from subcriteria where criteria = 'Projection and Stage Presence')),
(46,91,1,1,4,'00001',(select id from subcriteria where criteria = 'First Impression')),
(47,92,1,1,5,'00001',(select id from subcriteria where criteria = 'Totality of Elements'));
/*!40000 ALTER TABLE `tally` ENABLE KEYS */;
and change the sql statement to
Bookmarks