--
-- Host: 127.0.0.1    Database: mrandmsjblf
-- ------------------------------------------------------


--
-- Temporary view structure for view `ave_final_interview`
--

/*!50001 DROP VIEW IF EXISTS `ave_final_interview`*/;
/*!50001 CREATE VIEW `ave_final_interview` AS SELECT 
 1 AS `candidate_id`,
 1 AS `gender`,
 1 AS `ave`*/;

--
-- Temporary view structure for view `ave_formal_wear`
--

/*!50001 DROP VIEW IF EXISTS `ave_formal_wear`*/;
/*!50001 CREATE VIEW `ave_formal_wear` AS SELECT 
 1 AS `candidate_id`,
 1 AS `gender`,
 1 AS `ave`*/;

--
-- Temporary view structure for view `ave_formal_wear_f`
--

/*!50001 DROP VIEW IF EXISTS `ave_formal_wear_f`*/;
/*!50001 CREATE VIEW `ave_formal_wear_f` AS SELECT 
 1 AS `candidate_id`,
 1 AS `fullname`,
 1 AS `gender`,
 1 AS `average`,
 1 AS `number`,
 1 AS `judge_1`,
 1 AS `judge_2`,
 1 AS `judge_3`*/;

--
-- Temporary view structure for view `ave_formal_wear_m`
--

/*!50001 DROP VIEW IF EXISTS `ave_formal_wear_m`*/;
/*!50001 CREATE VIEW `ave_formal_wear_m` AS SELECT 
 1 AS `candidate_id`,
 1 AS `fullname`,
 1 AS `gender`,
 1 AS `average`,
 1 AS `number`,
 1 AS `judge_1`,
 1 AS `judge_2`,
 1 AS `judge_3`*/;

--
-- Temporary view structure for view `ave_interview`
--

/*!50001 DROP VIEW IF EXISTS `ave_interview`*/;
/*!50001 CREATE VIEW `ave_interview` AS SELECT 
 1 AS `candidate_id`,
 1 AS `gender`,
 1 AS `ave`*/;

--
-- Temporary view structure for view `ave_interview_f`
--

/*!50001 DROP VIEW IF EXISTS `ave_interview_f`*/;
/*!50001 CREATE VIEW `ave_interview_f` AS SELECT 
 1 AS `candidate_id`,
 1 AS `fullname`,
 1 AS `gender`,
 1 AS `average`,
 1 AS `number`,
 1 AS `judge_1`,
 1 AS `judge_2`,
 1 AS `judge_3`*/;

--
-- Temporary view structure for view `ave_interview_m`
--

/*!50001 DROP VIEW IF EXISTS `ave_interview_m`*/;
/*!50001 CREATE VIEW `ave_interview_m` AS SELECT 
 1 AS `candidate_id`,
 1 AS `fullname`,
 1 AS `gender`,
 1 AS `average`,
 1 AS `number`,
 1 AS `judge_1`,
 1 AS `judge_2`,
 1 AS `judge_3`*/;

--
-- Temporary view structure for view `ave_new_criteria`
--

/*!50001 DROP VIEW IF EXISTS `ave_new_criteria`*/;
/*!50001 CREATE VIEW `ave_new_criteria` AS SELECT 
 1 AS `candidate_id`,
 1 AS `gender`,
 1 AS `ave`*/;

--
-- Temporary view structure for view `ave_prod_number`
--

/*!50001 DROP VIEW IF EXISTS `ave_prod_number`*/;
/*!50001 CREATE VIEW `ave_prod_number` AS SELECT 
 1 AS `candidate_id`,
 1 AS `gender`,
 1 AS `ave`*/;

--
-- Temporary view structure for view `ave_prodnumber_f`
--

/*!50001 DROP VIEW IF EXISTS `ave_prodnumber_f`*/;
/*!50001 CREATE VIEW `ave_prodnumber_f` AS SELECT 
 1 AS `candidate_id`,
 1 AS `fullname`,
 1 AS `gender`,
 1 AS `average`,
 1 AS `number`,
 1 AS `judge_1`,
 1 AS `judge_2`,
 1 AS `judge_3`*/;

--
-- Temporary view structure for view `ave_prodnumber_m`
--

/*!50001 DROP VIEW IF EXISTS `ave_prodnumber_m`*/;
/*!50001 CREATE VIEW `ave_prodnumber_m` AS SELECT 
 1 AS `candidate_id`,
 1 AS `fullname`,
 1 AS `gender`,
 1 AS `average`,
 1 AS `number`,
 1 AS `judge_1`,
 1 AS `judge_2`,
 1 AS `judge_3`*/;

--
-- Temporary view structure for view `ave_swim_wear`
--

/*!50001 DROP VIEW IF EXISTS `ave_swim_wear`*/;
/*!50001 CREATE VIEW `ave_swim_wear` AS SELECT 
 1 AS `candidate_id`,
 1 AS `gender`,
 1 AS `ave`*/;

--
-- Temporary view structure for view `ave_swimwear_f`
--

/*!50001 DROP VIEW IF EXISTS `ave_swimwear_f`*/;
/*!50001 CREATE VIEW `ave_swimwear_f` AS SELECT 
 1 AS `candidate_id`,
 1 AS `fullname`,
 1 AS `gender`,
 1 AS `average`,
 1 AS `number`,
 1 AS `judge_1`,
 1 AS `judge_2`,
 1 AS `judge_3`*/;

--
-- Temporary view structure for view `ave_swimwear_m`
--

/*!50001 DROP VIEW IF EXISTS `ave_swimwear_m`*/;
/*!50001 CREATE VIEW `ave_swimwear_m` AS SELECT 
 1 AS `candidate_id`,
 1 AS `fullname`,
 1 AS `gender`,
 1 AS `average`,
 1 AS `number`,
 1 AS `judge_1`,
 1 AS `judge_2`,
 1 AS `judge_3`*/;

--
-- Temporary view structure for view `ave_talent`
--

/*!50001 DROP VIEW IF EXISTS `ave_talent`*/;
/*!50001 CREATE VIEW `ave_talent` AS SELECT 
 1 AS `candidate_id`,
 1 AS `gender`,
 1 AS `ave`*/;

--
-- Temporary view structure for view `ave_talent_f`
--

/*!50001 DROP VIEW IF EXISTS `ave_talent_f`*/;
/*!50001 CREATE VIEW `ave_talent_f` AS SELECT 
 1 AS `candidate_id`,
 1 AS `fullname`,
 1 AS `gender`,
 1 AS `average`,
 1 AS `number`,
 1 AS `judge_1`,
 1 AS `judge_2`,
 1 AS `judge_3`*/;

--
-- Temporary view structure for view `ave_talent_m`
--

/*!50001 DROP VIEW IF EXISTS `ave_talent_m`*/;
/*!50001 CREATE VIEW `ave_talent_m` AS SELECT 
 1 AS `candidate_id`,
 1 AS `fullname`,
 1 AS `gender`,
 1 AS `average`,
 1 AS `number`,
 1 AS `judge_1`,
 1 AS `judge_2`,
 1 AS `judge_3`*/;

--
-- Table structure for table `candidates`
--

CREATE TABLE `candidates` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `number` int(11) DEFAULT NULL,
  `fullname` varchar(100) DEFAULT NULL,
  `gender` tinyint(1) DEFAULT NULL COMMENT '0 = female;\n1 = male;',
  `finalist` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `candidates`
--

INSERT INTO `candidates` VALUES (1,1,'MS 1',0,1),(2,2,'MS 2',0,0),(3,3,'MS 3',0,0),(4,4,'MS 4',0,0),(5,5,'MS 5',0,1),(6,6,'MS 6',0,1),(7,7,'MR7',1,0),(8,8,'MR 8',1,1),(9,9,'MR 9',1,0),(10,10,'MR 10',1,0),(11,11,'MR 11',1,1),(12,12,'MR 12',1,1);

--
-- Table structure for table `criteria`
--

CREATE TABLE `criteria` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(45) DEFAULT NULL,
  `subcriteria` text,
  `percentage` text NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `criteria`
--

INSERT INTO `criteria` VALUES (1,'PRODUCTION NUMBER','Personality/ Beauty of the Face;Poise, Bearing and Projection;Mastery and Stage Presence;Composure / Deportment','30;30;30;10'),(2,'PLAYSUIT','Masculinity/ Femininity<br>(Physique and Body Structure);Poise, Carriage, and  Bearing;Composure / Deportment;Stage Presence','40;20;20;20'),(3,'TALENT','Skills;Performance;Mastery;Uniqueness','40;30;20;10'),(4,'FORMAL WEAR','Stage Presence<br>(Suitability, Elegance, Charm);Masculinity/ Femininity;Poise, Carriage, and  Bearing;Composure and Deportment','20;40;20;20'),(5,'PRELIMINARY INTERVIEW','Organization<br>(Arrangement of thought, Presentation);Delivery<br>(Spontaneity, Facility of language);Wit<br>(Choice of words, Humor);Content<br>(Astuteness of perception of judgement, Reasoning, Logic)','20;30;20;30'),(6,'FINAL INTERVIEW','BEAUTY<br>(Includes facial beauty, body proportion, and the judges’ over-all impression of the contestants throughout the contest);INTELLIGENCE<br>(Organization-Arrangemant of Thougth, Presentation), Delivery-Spontaniety, Faciltiy of Languange, Wit-Choice of Words, Humor','50;50');

--
-- Table structure for table `deductions`
--

CREATE TABLE `deductions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `candidate_id` int(11) NOT NULL,
  `deductions` double NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `deductions`
--

INSERT INTO `deductions` VALUES (1,1,0),(2,2,0),(3,3,0),(4,4,0),(5,5,0),(6,6,0),(7,7,0),(8,8,0),(9,9,0),(10,10,0),(11,11,0),(12,12,0),(13,13,0),(14,14,0),(15,15,0);

--
-- Table structure for table `final_interview`
--

CREATE TABLE `final_interview` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `candidate_id` int(11) DEFAULT NULL,
  `judge_id` int(11) DEFAULT NULL,
  `sub1` double NOT NULL DEFAULT '0',
  `sub2` double NOT NULL DEFAULT '0',
  `sub3` double NOT NULL DEFAULT '0',
  `total` double NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `fk_final_interview_candidates1_idx` (`candidate_id`),
  KEY `fk_final_interview_judges1_idx` (`judge_id`),
  CONSTRAINT `fk_final_interview_candidates1` FOREIGN KEY (`candidate_id`) REFERENCES `candidates` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_final_interview_judges1` FOREIGN KEY (`judge_id`) REFERENCES `judges` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=43 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `final_interview`
--

INSERT INTO `final_interview` VALUES (1,1,4,47,48,0,95),(2,5,4,48,50,0,98),(3,6,4,49,50,0,99),(4,8,4,47,48,0,95),(5,11,4,48,47,0,95),(6,12,4,48,50,0,98),(7,1,2,45,45,0,90),(8,5,2,40,43,0,83),(9,6,2,43,30,0,73),(10,8,2,40,40,0,80),(11,11,2,43,35,0,78),(12,12,2,45,45,0,90),(13,1,6,47,43,0,90),(14,5,6,45,48,0,93),(15,6,6,44,42,0,86),(16,8,6,48,40,0,88),(17,11,6,45,44,0,89),(18,12,6,46,47,0,93),(19,1,7,48,47,0,95),(20,5,7,45,48,0,93),(21,6,7,49,45,0,94),(22,8,7,46,45,0,91),(23,11,7,45,40,0,85),(24,12,7,47,49,0,96),(25,1,1,40,40,0,80),(26,5,1,43,45,0,88),(27,6,1,42,35,0,77),(28,8,1,35,30,0,65),(29,11,1,35,35,0,70),(30,12,1,45,40,0,85),(31,1,3,47,49,0,96),(32,5,3,43,48,0,91),(33,6,3,47,45,0,92),(34,8,3,47,43,0,90),(35,11,3,46,42,0,88),(36,12,3,48,48,0,96),(37,1,5,49,50,0,99),(38,5,5,46,47,0,93),(39,6,5,45,47,0,92),(40,8,5,45,47,0,92),(41,11,5,45,46,0,91),(42,12,5,49,49,0,98);

--
-- Temporary view structure for view `final_interview_rank_f`
--

/*!50001 DROP VIEW IF EXISTS `final_interview_rank_f`*/;
/*!50001 CREATE VIEW `final_interview_rank_f` AS SELECT 
 1 AS `id`,
 1 AS `number`,
 1 AS `fullname`,
 1 AS `j1_score`,
 1 AS `j1_rank`,
 1 AS `j2_score`,
 1 AS `j2_rank`,
 1 AS `j3_score`,
 1 AS `j3_rank`,
 1 AS `j4_score`,
 1 AS `j4_rank`,
 1 AS `j5_score`,
 1 AS `j5_rank`,
 1 AS `j6_score`,
 1 AS `j6_rank`,
 1 AS `j7_score`,
 1 AS `j7_rank`,
 1 AS `j8_score`,
 1 AS `j8_rank`,
 1 AS `j9_score`,
 1 AS `j9_rank`,
 1 AS `total_rank`*/;

--
-- Temporary view structure for view `final_interview_rank_m`
--

/*!50001 DROP VIEW IF EXISTS `final_interview_rank_m`*/;
/*!50001 CREATE VIEW `final_interview_rank_m` AS SELECT 
 1 AS `id`,
 1 AS `number`,
 1 AS `fullname`,
 1 AS `j1_score`,
 1 AS `j1_rank`,
 1 AS `j2_score`,
 1 AS `j2_rank`,
 1 AS `j3_score`,
 1 AS `j3_rank`,
 1 AS `j4_score`,
 1 AS `j4_rank`,
 1 AS `j5_score`,
 1 AS `j5_rank`,
 1 AS `j6_score`,
 1 AS `j6_rank`,
 1 AS `j7_score`,
 1 AS `j7_rank`,
 1 AS `j8_score`,
 1 AS `j8_rank`,
 1 AS `j9_score`,
 1 AS `j9_rank`,
 1 AS `total_rank`*/;

--
-- Table structure for table `formal_wear`
--

CREATE TABLE `formal_wear` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `candidate_id` int(11) DEFAULT NULL,
  `judge_id` int(11) DEFAULT NULL,
  `sub1` double NOT NULL DEFAULT '0',
  `sub2` double NOT NULL DEFAULT '0',
  `sub3` double NOT NULL DEFAULT '0',
  `sub4` double NOT NULL DEFAULT '0',
  `total` double NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `fk_evening_gown_candidates1_idx` (`candidate_id`),
  KEY `fk_evening_gown_judges1_idx` (`judge_id`)
) ENGINE=InnoDB AUTO_INCREMENT=85 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `formal_wear`
--

INSERT INTO `formal_wear` VALUES (1,1,3,19,37,18,17,91),(2,2,3,16,35,17,16,84),(3,3,3,17,36,18,17,88),(4,4,3,16,35,16,16,83),(5,5,3,17,34,15,16,82),(6,6,3,18,37,18,19,92),(7,7,3,17,36,16,17,86),(8,8,3,18,36,18,17,89),(9,9,3,17,36,17,17,87),(10,10,3,16,35,16,16,83),(11,11,3,17,36,17,17,87),(12,12,3,18,36,17,17,88),(13,1,2,18,38,18,18,92),(14,2,2,15,32,16,16,79),(15,3,2,16,35,17,17,85),(16,4,2,16,33,16,16,81),(17,5,2,17,36,18,17,88),(18,6,2,16,35,15,16,82),(19,7,2,15,37,14,17,83),(20,8,2,18,36,17,18,89),(21,9,2,14,33,14,16,77),(22,10,2,14,33,13,15,75),(23,11,2,17,37,17,17,88),(24,12,2,17,36,16,17,86),(25,1,6,18,40,20,20,98),(26,2,6,17,39,18,20,94),(27,3,6,17,38,19,20,94),(28,4,6,20,39,19,20,98),(29,5,6,17,39,19,20,95),(30,6,6,18,39,19,20,96),(31,7,6,17,36,18,20,91),(32,8,6,19,39,18,20,96),(33,9,6,17,37,18,20,92),(34,10,6,18,35,18,20,91),(35,11,6,17,37,18,20,92),(36,12,6,19,38,20,20,97),(37,1,4,20,39,19,20,98),(38,2,4,18,37,18,18,91),(39,3,4,19,38,18,19,94),(40,4,4,18,38,18,18,92),(41,5,4,20,39,20,19,98),(42,6,4,19,38,19,19,95),(43,7,4,18,37,18,18,91),(44,8,4,19,38,19,18,94),(45,9,4,20,40,19,18,97),(46,10,4,19,39,20,19,97),(47,11,4,20,39,19,20,98),(48,12,4,20,40,20,19,99),(49,1,7,18,38,17,18,91),(50,2,7,18,37,18,17,90),(51,3,7,20,39,18,18,95),(52,4,7,20,39,19,18,96),(53,5,7,18,38,18,19,93),(54,6,7,17,39,17,19,92),(55,7,7,18,37,18,18,91),(56,8,7,19,37,16,17,89),(57,9,7,18,38,17,18,91),(58,10,7,17,37,17,19,90),(59,11,7,17,38,17,18,90),(60,12,7,19,38,18,18,93),(61,1,5,20,37,20,19,96),(62,2,5,18,31,17,17,83),(63,3,5,20,38,18,18,94),(64,4,5,18,36,17,18,89),(65,5,5,18,36,19,18,91),(66,6,5,18,35,18,17,88),(67,7,5,17,34,17,17,85),(68,8,5,19,36,19,19,93),(69,9,5,17,34,18,18,87),(70,10,5,18,37,17,18,90),(71,11,5,18,35,18,17,88),(72,12,5,19,35,19,18,91),(73,1,1,17,32,16,16,81),(74,2,1,15,27,13,15,70),(75,3,1,18,38,17,17,90),(76,4,1,15,28,14,14,71),(77,5,1,16,30,17,17,80),(78,6,1,18,35,17,17,87),(79,7,1,17,33,17,15,82),(80,8,1,18,37,18,17,90),(81,9,1,13,20,13,13,59),(82,10,1,15,28,15,15,73),(83,11,1,16,33,17,17,83),(84,12,1,17,34,17,18,86);

--
-- Temporary view structure for view `formal_wear_rank_f`
--

/*!50001 DROP VIEW IF EXISTS `formal_wear_rank_f`*/;
/*!50001 CREATE VIEW `formal_wear_rank_f` AS SELECT 
 1 AS `id`,
 1 AS `number`,
 1 AS `fullname`,
 1 AS `j1_score`,
 1 AS `j1_rank`,
 1 AS `j2_score`,
 1 AS `j2_rank`,
 1 AS `j3_score`,
 1 AS `j3_rank`,
 1 AS `j4_score`,
 1 AS `j4_rank`,
 1 AS `j5_score`,
 1 AS `j5_rank`,
 1 AS `j6_score`,
 1 AS `j6_rank`,
 1 AS `j7_score`,
 1 AS `j7_rank`,
 1 AS `j8_score`,
 1 AS `j8_rank`,
 1 AS `j9_score`,
 1 AS `j9_rank`,
 1 AS `total_rank`*/;

--
-- Temporary view structure for view `formal_wear_rank_m`
--

/*!50001 DROP VIEW IF EXISTS `formal_wear_rank_m`*/;
/*!50001 CREATE VIEW `formal_wear_rank_m` AS SELECT 
 1 AS `id`,
 1 AS `number`,
 1 AS `fullname`,
 1 AS `j1_score`,
 1 AS `j1_rank`,
 1 AS `j2_score`,
 1 AS `j2_rank`,
 1 AS `j3_score`,
 1 AS `j3_rank`,
 1 AS `j4_score`,
 1 AS `j4_rank`,
 1 AS `j5_score`,
 1 AS `j5_rank`,
 1 AS `j6_score`,
 1 AS `j6_rank`,
 1 AS `j7_score`,
 1 AS `j7_rank`,
 1 AS `j8_score`,
 1 AS `j8_rank`,
 1 AS `j9_score`,
 1 AS `j9_rank`,
 1 AS `total_rank`*/;

--
-- Table structure for table `interview`
--

CREATE TABLE `interview` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `candidate_id` int(11) DEFAULT NULL,
  `judge_id` int(11) DEFAULT NULL,
  `sub1` double NOT NULL DEFAULT '0',
  `sub2` double NOT NULL DEFAULT '0',
  `sub3` double NOT NULL DEFAULT '0',
  `sub4` double NOT NULL DEFAULT '0',
  `total` double NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `fk_interview_candidates1_idx` (`candidate_id`),
  KEY `fk_interview_judges1_idx` (`judge_id`),
  CONSTRAINT `fk_interview_candidates1` FOREIGN KEY (`candidate_id`) REFERENCES `candidates` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_interview_judges1` FOREIGN KEY (`judge_id`) REFERENCES `judges` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=85 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `interview`
--

INSERT INTO `interview` VALUES (1,1,3,18,27,16,28,89),(2,2,3,16,22,15,26,79),(3,3,3,15,20,15,25,75),(4,4,3,17,26,16,27,86),(5,5,3,19,27,18,29,93),(6,6,3,19,28,17,28,92),(7,7,3,16,24,16,25,81),(8,8,3,16,25,16,26,83),(9,9,3,17,26,17,26,86),(10,10,3,17,25,16,26,84),(11,11,3,16,25,17,24,82),(12,12,3,18,27,18,28,91),(13,1,6,17,24,16,26,83),(14,2,6,17,26,17,28,88),(15,3,6,10,20,10,18,58),(16,4,6,20,29,19,30,98),(17,5,6,20,29,19,29,97),(18,6,6,18,26,18,25,87),(19,7,6,16,25,17,25,83),(20,8,6,15,25,18,24,82),(21,9,6,18,28,19,28,93),(22,10,6,16,26,17,26,85),(23,11,6,16,26,17,24,83),(24,12,6,19,29,20,28,96),(25,1,7,17,28,18,27,90),(26,2,7,18,27,16,17,78),(27,3,7,16,24,15,25,80),(28,4,7,18,29,19,28,94),(29,5,7,18,28,18,27,91),(30,6,7,17,28,19,27,91),(31,7,7,16,26,15,25,82),(32,8,7,17,25,15,24,81),(33,9,7,16,26,17,26,85),(34,10,7,15,20,15,20,70),(35,11,7,15,20,14,20,69),(36,12,7,17,27,17,27,88),(37,1,1,15,20,15,20,70),(38,2,1,12,13,10,15,50),(39,3,1,10,10,10,10,40),(40,4,1,15,21,16,22,74),(41,5,1,18,22,18,24,82),(42,6,1,17,20,17,21,75),(43,7,1,17,22,17,20,76),(44,8,1,18,25,18,23,84),(45,9,1,15,23,17,21,76),(46,10,1,10,10,10,10,40),(47,11,1,12,20,16,13,61),(48,12,1,16,23,17,17,73),(49,1,2,17,28,16,27,88),(50,2,2,15,25,13,25,78),(51,3,2,10,20,10,20,60),(52,4,2,17,25,18,25,85),(53,5,2,18,28,17,28,91),(54,6,2,17,27,17,26,87),(55,7,2,14,24,15,24,77),(56,8,2,16,26,17,25,84),(57,9,2,15,23,16,24,78),(58,10,2,16,26,17,26,85),(59,11,2,14,23,15,24,76),(60,12,2,18,26,18,27,89),(61,1,5,19,29,20,29,97),(62,2,5,17,26,18,27,88),(63,3,5,17,21,17,22,77),(64,4,5,18,28,20,28,94),(65,5,5,19,28,20,29,96),(66,6,5,19,29,20,27,95),(67,7,5,17,25,19,25,86),(68,8,5,17,26,18,27,88),(69,9,5,19,28,17,28,92),(70,10,5,19,26,18,25,88),(71,11,5,18,26,18,26,88),(72,12,5,19,27,19,29,94),(73,1,4,19,30,19,30,98),(74,2,4,18,27,17,27,89),(75,3,4,18,27,17,26,88),(76,4,4,19,28,19,28,94),(77,5,4,20,30,19,29,98),(78,6,4,20,29,20,29,98),(79,7,4,18,27,18,27,90),(80,8,4,19,28,19,28,94),(81,9,4,20,28,18,28,94),(82,10,4,19,29,18,28,94),(83,11,4,19,29,18,28,94),(84,12,4,20,30,19,30,99);

--
-- Temporary view structure for view `interview_rank_f`
--

/*!50001 DROP VIEW IF EXISTS `interview_rank_f`*/;
/*!50001 CREATE VIEW `interview_rank_f` AS SELECT 
 1 AS `id`,
 1 AS `number`,
 1 AS `fullname`,
 1 AS `j1_score`,
 1 AS `j1_rank`,
 1 AS `j2_score`,
 1 AS `j2_rank`,
 1 AS `j3_score`,
 1 AS `j3_rank`,
 1 AS `j4_score`,
 1 AS `j4_rank`,
 1 AS `j5_score`,
 1 AS `j5_rank`,
 1 AS `j6_score`,
 1 AS `j6_rank`,
 1 AS `j7_score`,
 1 AS `j7_rank`,
 1 AS `j8_score`,
 1 AS `j8_rank`,
 1 AS `j9_score`,
 1 AS `j9_rank`,
 1 AS `total_rank`*/;

--
-- Temporary view structure for view `interview_rank_m`
--

/*!50001 DROP VIEW IF EXISTS `interview_rank_m`*/;
/*!50001 CREATE VIEW `interview_rank_m` AS SELECT 
 1 AS `id`,
 1 AS `number`,
 1 AS `fullname`,
 1 AS `j1_score`,
 1 AS `j1_rank`,
 1 AS `j2_score`,
 1 AS `j2_rank`,
 1 AS `j3_score`,
 1 AS `j3_rank`,
 1 AS `j4_score`,
 1 AS `j4_rank`,
 1 AS `j5_score`,
 1 AS `j5_rank`,
 1 AS `j6_score`,
 1 AS `j6_rank`,
 1 AS `j7_score`,
 1 AS `j7_rank`,
 1 AS `j8_score`,
 1 AS `j8_rank`,
 1 AS `j9_score`,
 1 AS `j9_rank`,
 1 AS `total_rank`*/;

--
-- Table structure for table `judges`
--

CREATE TABLE `judges` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `judge_no` int(11) DEFAULT NULL,
  `judge_name` varchar(100) DEFAULT NULL,
  `remarks` varchar(45) DEFAULT NULL,
  `is_used` tinyint(1) DEFAULT NULL,
  `assigned` tinyint(1) DEFAULT NULL COMMENT '0: Female\n1: Male',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `judges`
--

INSERT INTO `judges` VALUES (1,1,'J1','5',1,0),(2,2,'J2','6',0,0),(3,3,'J3','2',0,0),(4,4,'J4','7',0,0),(5,5,'J5','1',0,0),(6,6,'J6','3',0,0),(7,7,'J7','4',0,0),(8,8,'J8','',0,0),(9,9,'J9','',0,0);

--
-- Table structure for table `new_criteria`
--

CREATE TABLE `new_criteria` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `candidate_id` int(11) NOT NULL,
  `judge_id` int(11) NOT NULL,
  `sub1` double NOT NULL DEFAULT '0',
  `sub2` double NOT NULL DEFAULT '0',
  `sub3` double NOT NULL DEFAULT '0',
  `sub4` double NOT NULL DEFAULT '0',
  `total` double NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `new_criteria`
--


--
-- Table structure for table `new_criteria2`
--

CREATE TABLE `new_criteria2` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `candidate_id` int(11) NOT NULL,
  `judge_id` int(11) NOT NULL,
  `sub1` double NOT NULL DEFAULT '0',
  `sub2` double NOT NULL DEFAULT '0',
  `sub3` double NOT NULL DEFAULT '0',
  `sub4` double NOT NULL DEFAULT '0',
  `total` double NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `new_criteria2`
--


--
-- Temporary view structure for view `new_criteria2_rank_f`
--

/*!50001 DROP VIEW IF EXISTS `new_criteria2_rank_f`*/;
/*!50001 CREATE VIEW `new_criteria2_rank_f` AS SELECT 
 1 AS `id`,
 1 AS `number`,
 1 AS `fullname`,
 1 AS `j1_score`,
 1 AS `j1_rank`,
 1 AS `j2_score`,
 1 AS `j2_rank`,
 1 AS `j3_score`,
 1 AS `j3_rank`,
 1 AS `j4_score`,
 1 AS `j4_rank`,
 1 AS `j5_score`,
 1 AS `j5_rank`,
 1 AS `j6_score`,
 1 AS `j6_rank`,
 1 AS `j7_score`,
 1 AS `j7_rank`,
 1 AS `j8_score`,
 1 AS `j8_rank`,
 1 AS `j9_score`,
 1 AS `j9_rank`,
 1 AS `total_rank`*/;

--
-- Temporary view structure for view `new_criteria2_rank_m`
--

/*!50001 DROP VIEW IF EXISTS `new_criteria2_rank_m`*/;
/*!50001 CREATE VIEW `new_criteria2_rank_m` AS SELECT 
 1 AS `id`,
 1 AS `number`,
 1 AS `fullname`,
 1 AS `j1_score`,
 1 AS `j1_rank`,
 1 AS `j2_score`,
 1 AS `j2_rank`,
 1 AS `j3_score`,
 1 AS `j3_rank`,
 1 AS `j4_score`,
 1 AS `j4_rank`,
 1 AS `j5_score`,
 1 AS `j5_rank`,
 1 AS `j6_score`,
 1 AS `j6_rank`,
 1 AS `j7_score`,
 1 AS `j7_rank`,
 1 AS `j8_score`,
 1 AS `j8_rank`,
 1 AS `j9_score`,
 1 AS `j9_rank`,
 1 AS `total_rank`*/;

--
-- Temporary view structure for view `new_criteria_rank_f`
--

/*!50001 DROP VIEW IF EXISTS `new_criteria_rank_f`*/;
/*!50001 CREATE VIEW `new_criteria_rank_f` AS SELECT 
 1 AS `id`,
 1 AS `number`,
 1 AS `fullname`,
 1 AS `j1_score`,
 1 AS `j1_rank`,
 1 AS `j2_score`,
 1 AS `j2_rank`,
 1 AS `j3_score`,
 1 AS `j3_rank`,
 1 AS `j4_score`,
 1 AS `j4_rank`,
 1 AS `j5_score`,
 1 AS `j5_rank`,
 1 AS `j6_score`,
 1 AS `j6_rank`,
 1 AS `j7_score`,
 1 AS `j7_rank`,
 1 AS `j8_score`,
 1 AS `j8_rank`,
 1 AS `j9_score`,
 1 AS `j9_rank`,
 1 AS `total_rank`*/;

--
-- Temporary view structure for view `new_criteria_rank_m`
--

/*!50001 DROP VIEW IF EXISTS `new_criteria_rank_m`*/;
/*!50001 CREATE VIEW `new_criteria_rank_m` AS SELECT 
 1 AS `id`,
 1 AS `number`,
 1 AS `fullname`,
 1 AS `j1_score`,
 1 AS `j1_rank`,
 1 AS `j2_score`,
 1 AS `j2_rank`,
 1 AS `j3_score`,
 1 AS `j3_rank`,
 1 AS `j4_score`,
 1 AS `j4_rank`,
 1 AS `j5_score`,
 1 AS `j5_rank`,
 1 AS `j6_score`,
 1 AS `j6_rank`,
 1 AS `j7_score`,
 1 AS `j7_rank`,
 1 AS `j8_score`,
 1 AS `j8_rank`,
 1 AS `j9_score`,
 1 AS `j9_rank`,
 1 AS `total_rank`*/;

--
-- Table structure for table `prod_number`
--

CREATE TABLE `prod_number` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `candidate_id` int(11) DEFAULT NULL,
  `judge_id` int(11) DEFAULT NULL,
  `sub1` double NOT NULL DEFAULT '0',
  `sub2` double NOT NULL DEFAULT '0',
  `sub3` double NOT NULL DEFAULT '0',
  `sub4` double NOT NULL DEFAULT '0',
  `sub5` double NOT NULL DEFAULT '0',
  `total` double NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `fk_prod_number_candidates_idx` (`candidate_id`),
  KEY `fk_prod_number_judges1_idx` (`judge_id`),
  CONSTRAINT `fk_prod_number_candidates` FOREIGN KEY (`candidate_id`) REFERENCES `candidates` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_prod_number_judges1` FOREIGN KEY (`judge_id`) REFERENCES `judges` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=85 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `prod_number`
--

INSERT INTO `prod_number` VALUES (1,1,3,27,28,25,10,0,90),(2,2,3,25,25,23,10,0,83),(3,3,3,28,26,25,10,0,89),(4,4,3,26,24,24,10,0,84),(5,5,3,24,25,24,10,0,83),(6,6,3,26,27,26,10,0,89),(7,7,3,25,25,25,10,0,85),(8,8,3,26,25,26,10,0,87),(9,9,3,24,25,26,10,0,85),(10,10,3,25,24,26,10,0,85),(11,11,3,27,27,26,10,0,90),(12,12,3,26,25,25,10,0,86),(13,1,4,28,28,29,10,0,95),(14,2,4,25,26,25,9,0,85),(15,3,4,25,25,22,10,0,82),(16,4,4,27,23,26,9,0,85),(17,5,4,29,28,29,10,0,96),(18,6,4,23,25,27,10,0,85),(19,7,4,25,28,27,9,0,89),(20,8,4,28,27,27,10,0,92),(21,9,4,27,27,27,10,0,91),(22,10,4,29,29,29,10,0,97),(23,11,4,29,30,30,10,0,99),(24,12,4,27,27,27,9,0,90),(25,1,2,27,28,28,8,0,91),(26,2,2,25,20,25,7,0,77),(27,3,2,28,27,26,7,0,88),(28,4,2,23,26,25,6,0,80),(29,5,2,26,27,27,8,0,88),(30,6,2,25,25,24,7,0,81),(31,7,2,28,26,25,8,0,87),(32,8,2,27,24,26,6,0,83),(33,9,2,20,25,25,7,0,77),(34,10,2,24,23,25,5,0,77),(35,11,2,28,28,27,8,0,91),(36,12,2,27,26,25,7,0,85),(37,1,5,25,28,28,9,0,90),(38,2,5,23,26,25,7,0,81),(39,3,5,26,26,26,9,0,87),(40,4,5,23,25,26,7,0,81),(41,5,5,25,28,27,9,0,89),(42,6,5,24,25,27,8,0,84),(43,7,5,23,25,26,7,0,81),(44,8,5,28,26,27,8,0,89),(45,9,5,23,25,26,8,0,82),(46,10,5,24,28,29,9,0,90),(47,11,5,25,28,27,9,0,89),(48,12,5,24,27,27,8,0,86),(49,1,6,30,25,23,10,0,88),(50,2,6,30,26,23,10,0,89),(51,3,6,30,26,25,10,0,91),(52,4,6,30,26,25,10,0,91),(53,5,6,30,28,28,10,0,96),(54,6,6,30,22,28,10,0,90),(55,7,6,30,24,23,10,0,87),(56,8,6,30,27,28,10,0,95),(57,9,6,30,23,26,10,0,89),(58,10,6,30,27,29,10,0,96),(59,11,6,30,28,26,10,0,94),(60,12,6,30,27,27,10,0,94),(61,1,7,20,20,15,10,0,65),(62,2,7,20,15,15,8,0,58),(63,3,7,25,20,20,10,0,75),(64,4,7,25,20,10,10,0,65),(65,5,7,20,25,30,10,0,85),(66,6,7,15,15,20,10,0,60),(67,7,7,20,20,15,6,0,61),(68,8,7,30,25,20,9,0,84),(69,9,7,15,20,20,8,0,63),(70,10,7,15,20,20,9,0,64),(71,11,7,25,15,20,7,0,67),(72,12,7,15,20,15,6,0,56),(73,1,1,28,28,28,9,0,93),(74,2,1,23,23,25,7,0,78),(75,3,1,25,25,25,7,0,82),(76,4,1,20,20,20,6,0,66),(77,5,1,20,20,23,6,0,69),(78,6,1,23,23,23,6,0,75),(79,7,1,23,23,25,8,0,79),(80,8,1,21,21,25,7,0,74),(81,9,1,20,20,20,5,0,65),(82,10,1,25,25,25,8,0,83),(83,11,1,23,25,25,7,0,80),(84,12,1,22,22,26,8,0,78);

--
-- Temporary view structure for view `prod_number_rank_f`
--

/*!50001 DROP VIEW IF EXISTS `prod_number_rank_f`*/;
/*!50001 CREATE VIEW `prod_number_rank_f` AS SELECT 
 1 AS `id`,
 1 AS `number`,
 1 AS `fullname`,
 1 AS `j1_score`,
 1 AS `j1_rank`,
 1 AS `j2_score`,
 1 AS `j2_rank`,
 1 AS `j3_score`,
 1 AS `j3_rank`,
 1 AS `j4_score`,
 1 AS `j4_rank`,
 1 AS `j5_score`,
 1 AS `j5_rank`,
 1 AS `j6_score`,
 1 AS `j6_rank`,
 1 AS `j7_score`,
 1 AS `j7_rank`,
 1 AS `j8_score`,
 1 AS `j8_rank`,
 1 AS `j9_score`,
 1 AS `j9_rank`,
 1 AS `total_rank`*/;

--
-- Temporary view structure for view `prod_number_rank_m`
--

/*!50001 DROP VIEW IF EXISTS `prod_number_rank_m`*/;
/*!50001 CREATE VIEW `prod_number_rank_m` AS SELECT 
 1 AS `id`,
 1 AS `number`,
 1 AS `fullname`,
 1 AS `j1_score`,
 1 AS `j1_rank`,
 1 AS `j2_score`,
 1 AS `j2_rank`,
 1 AS `j3_score`,
 1 AS `j3_rank`,
 1 AS `j4_score`,
 1 AS `j4_rank`,
 1 AS `j5_score`,
 1 AS `j5_rank`,
 1 AS `j6_score`,
 1 AS `j6_rank`,
 1 AS `j7_score`,
 1 AS `j7_rank`,
 1 AS `j8_score`,
 1 AS `j8_rank`,
 1 AS `j9_score`,
 1 AS `j9_rank`,
 1 AS `total_rank`*/;

--
-- Table structure for table `submits`
--

CREATE TABLE `submits` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `judge_id` int(11) NOT NULL,
  `criteria` int(11) NOT NULL,
  `submitted` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=43 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `submits`
--

INSERT INTO `submits` VALUES (1,1,3,1),(2,2,3,1),(3,3,3,1),(4,1,1,1),(5,2,1,1),(6,3,1,1),(7,4,1,1),(8,5,1,1),(9,6,1,1),(10,7,1,1),(11,8,1,0),(12,9,1,0),(13,1,2,1),(14,2,2,1),(15,3,2,1),(16,4,2,1),(17,5,2,1),(18,6,2,1),(19,7,2,1),(20,8,2,0),(21,9,2,0),(22,1,4,1),(23,2,4,1),(24,3,4,1),(25,4,4,1),(26,5,4,1),(27,6,4,1),(28,7,4,1),(29,1,5,1),(30,2,5,1),(31,3,5,1),(32,4,5,1),(33,5,5,1),(34,6,5,1),(35,7,5,1),(36,1,6,1),(37,2,6,1),(38,3,6,1),(39,4,6,1),(40,5,6,1),(41,6,6,1),(42,7,6,1);

--
-- Table structure for table `swim_wear`
--

CREATE TABLE `swim_wear` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `candidate_id` int(11) DEFAULT NULL,
  `judge_id` int(11) DEFAULT NULL,
  `sub1` double NOT NULL DEFAULT '0',
  `sub2` double NOT NULL DEFAULT '0',
  `sub3` double NOT NULL DEFAULT '0',
  `sub4` double NOT NULL DEFAULT '0',
  `total` double NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `fk_swim_wear_candidates1_idx` (`candidate_id`),
  KEY `fk_swim_wear_judges1_idx` (`judge_id`),
  CONSTRAINT `fk_swim_wear_candidates1` FOREIGN KEY (`candidate_id`) REFERENCES `candidates` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_swim_wear_judges1` FOREIGN KEY (`judge_id`) REFERENCES `judges` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=85 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `swim_wear`
--

INSERT INTO `swim_wear` VALUES (1,1,3,39,17,18,18,92),(2,2,3,35,16,16,16,83),(3,3,3,36,17,17,17,87),(4,4,3,35,17,16,16,84),(5,5,3,35,16,17,16,84),(6,6,3,37,18,18,18,91),(7,7,3,37,18,18,18,91),(8,8,3,36,17,17,17,87),(9,9,3,36,18,18,17,89),(10,10,3,32,15,16,15,78),(11,11,3,35,16,17,18,86),(12,12,3,36,16,17,18,87),(13,1,2,37,18,18,18,91),(14,2,2,33,15,15,17,80),(15,3,2,35,17,16,16,84),(16,4,2,33,17,17,15,82),(17,5,2,35,17,17,16,85),(18,6,2,34,15,16,16,81),(19,7,2,36,16,18,18,88),(20,8,2,35,17,17,18,87),(21,9,2,37,19,18,19,93),(22,10,2,33,15,16,16,80),(23,11,2,37,17,18,18,90),(24,12,2,35,16,17,17,85),(25,1,5,35,20,19,19,93),(26,2,5,33,20,18,16,87),(27,3,5,36,18,19,18,91),(28,4,5,32,17,17,17,83),(29,5,5,36,18,18,18,90),(30,6,5,34,18,16,18,86),(31,7,5,35,19,17,17,88),(32,8,5,36,19,18,18,91),(33,9,5,37,19,19,19,94),(34,10,5,35,17,18,19,89),(35,11,5,36,19,18,19,92),(36,12,5,35,18,18,18,89),(37,1,6,40,17,20,19,96),(38,2,6,38,18,20,18,94),(39,3,6,38,18,20,20,96),(40,4,6,37,16,20,20,93),(41,5,6,40,17,20,18,95),(42,6,6,39,17,20,20,96),(43,7,6,38,18,20,20,96),(44,8,6,39,19,20,20,98),(45,9,6,40,20,20,20,100),(46,10,6,35,18,20,19,92),(47,11,6,39,19,20,20,98),(48,12,6,39,19,20,20,98),(49,1,1,37,18,18,18,91),(50,2,1,28,15,13,15,71),(51,3,1,35,18,18,18,89),(52,4,1,29,15,16,16,76),(53,5,1,30,16,17,17,80),(54,6,1,33,17,16,16,82),(55,7,1,29,17,15,15,76),(56,8,1,32,17,18,18,85),(57,9,1,31,16,16,17,80),(58,10,1,30,17,17,17,81),(59,11,1,28,16,15,15,74),(60,12,1,30,15,15,16,76),(61,1,4,39,19,19,19,96),(62,2,4,38,18,18,19,93),(63,3,4,39,19,19,20,97),(64,4,4,38,18,18,18,92),(65,5,4,39,19,19,19,96),(66,6,4,37,18,19,19,93),(67,7,4,37,20,18,18,93),(68,8,4,37,18,18,19,92),(69,9,4,39,20,19,20,98),(70,10,4,38,19,19,19,95),(71,11,4,39,19,20,20,98),(72,12,4,38,18,19,19,94),(73,1,7,35,20,15,20,90),(74,2,7,30,18,15,17,80),(75,3,7,35,18,18,18,89),(76,4,7,30,20,18,20,88),(77,5,7,30,17,15,20,82),(78,6,7,40,18,18,19,95),(79,7,7,30,18,15,19,82),(80,8,7,38,18,18,17,91),(81,9,7,40,20,18,20,98),(82,10,7,30,17,17,18,82),(83,11,7,38,18,17,18,91),(84,12,7,38,17,18,17,90);

--
-- Temporary view structure for view `swim_wear_rank_f`
--

/*!50001 DROP VIEW IF EXISTS `swim_wear_rank_f`*/;
/*!50001 CREATE VIEW `swim_wear_rank_f` AS SELECT 
 1 AS `id`,
 1 AS `number`,
 1 AS `fullname`,
 1 AS `j1_score`,
 1 AS `j1_rank`,
 1 AS `j2_score`,
 1 AS `j2_rank`,
 1 AS `j3_score`,
 1 AS `j3_rank`,
 1 AS `j4_score`,
 1 AS `j4_rank`,
 1 AS `j5_score`,
 1 AS `j5_rank`,
 1 AS `j6_score`,
 1 AS `j6_rank`,
 1 AS `j7_score`,
 1 AS `j7_rank`,
 1 AS `j8_score`,
 1 AS `j8_rank`,
 1 AS `j9_score`,
 1 AS `j9_rank`,
 1 AS `total_rank`*/;

--
-- Temporary view structure for view `swim_wear_rank_m`
--

/*!50001 DROP VIEW IF EXISTS `swim_wear_rank_m`*/;
/*!50001 CREATE VIEW `swim_wear_rank_m` AS SELECT 
 1 AS `id`,
 1 AS `number`,
 1 AS `fullname`,
 1 AS `j1_score`,
 1 AS `j1_rank`,
 1 AS `j2_score`,
 1 AS `j2_rank`,
 1 AS `j3_score`,
 1 AS `j3_rank`,
 1 AS `j4_score`,
 1 AS `j4_rank`,
 1 AS `j5_score`,
 1 AS `j5_rank`,
 1 AS `j6_score`,
 1 AS `j6_rank`,
 1 AS `j7_score`,
 1 AS `j7_rank`,
 1 AS `j8_score`,
 1 AS `j8_rank`,
 1 AS `j9_score`,
 1 AS `j9_rank`,
 1 AS `total_rank`*/;

--
-- Temporary view structure for view `tabulation_f`
--

/*!50001 DROP VIEW IF EXISTS `tabulation_f`*/;
/*!50001 CREATE VIEW `tabulation_f` AS SELECT 
 1 AS `id`,
 1 AS `number`,
 1 AS `fullname`,
 1 AS `prodnum`,
 1 AS `computed_prodnum`,
 1 AS `swimwear`,
 1 AS `computed_swimwear`,
 1 AS `talent`,
 1 AS `computed_talent`,
 1 AS `formalwear`,
 1 AS `computed_formalwear`,
 1 AS `interview`,
 1 AS `computed_interview`,
 1 AS `computed_final`*/;

--
-- Temporary view structure for view `tabulation_f2`
--

/*!50001 DROP VIEW IF EXISTS `tabulation_f2`*/;
/*!50001 CREATE VIEW `tabulation_f2` AS SELECT 
 1 AS `id`,
 1 AS `number`,
 1 AS `fullname`,
 1 AS `prodnum`,
 1 AS `swimwear`,
 1 AS `talent`,
 1 AS `formalwear`,
 1 AS `interview`,
 1 AS `computed_final`*/;

--
-- Temporary view structure for view `tabulation_m`
--

/*!50001 DROP VIEW IF EXISTS `tabulation_m`*/;
/*!50001 CREATE VIEW `tabulation_m` AS SELECT 
 1 AS `id`,
 1 AS `number`,
 1 AS `fullname`,
 1 AS `prodnum`,
 1 AS `computed_prodnum`,
 1 AS `swimwear`,
 1 AS `computed_swimwear`,
 1 AS `talent`,
 1 AS `computed_talent`,
 1 AS `formalwear`,
 1 AS `computed_formalwear`,
 1 AS `interview`,
 1 AS `computed_interview`,
 1 AS `computed_final`*/;

--
-- Temporary view structure for view `tabulation_m2`
--

/*!50001 DROP VIEW IF EXISTS `tabulation_m2`*/;
/*!50001 CREATE VIEW `tabulation_m2` AS SELECT 
 1 AS `id`,
 1 AS `number`,
 1 AS `fullname`,
 1 AS `prodnum`,
 1 AS `swimwear`,
 1 AS `talent`,
 1 AS `formalwear`,
 1 AS `interview`,
 1 AS `computed_final`*/;

--
-- Table structure for table `talent`
--

CREATE TABLE `talent` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `candidate_id` int(11) DEFAULT NULL,
  `judge_id` int(11) DEFAULT NULL,
  `sub1` double NOT NULL DEFAULT '0',
  `sub2` double NOT NULL DEFAULT '0',
  `sub3` double NOT NULL DEFAULT '0',
  `sub4` double NOT NULL DEFAULT '0',
  `total` double NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `fk_casual_wear_candidates1_idx` (`candidate_id`),
  KEY `fk_casual_wear_judges1_idx` (`judge_id`)
) ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `talent`
--

INSERT INTO `talent` VALUES (1,1,1,0,0,0,0,80),(2,2,1,0,0,0,0,77),(3,3,1,0,0,0,0,88),(4,4,1,0,0,0,0,85),(5,5,1,0,0,0,0,84),(6,6,1,0,0,0,0,93),(7,7,1,0,0,0,0,80),(8,8,1,0,0,0,0,82),(9,9,1,0,0,0,0,75),(10,10,1,0,0,0,0,79),(11,11,1,0,0,0,0,89),(12,12,1,0,0,0,0,94),(13,1,2,0,0,0,0,81),(14,2,2,0,0,0,0,75),(15,3,2,0,0,0,0,76),(16,4,2,0,0,0,0,77),(17,5,2,0,0,0,0,73),(18,6,2,0,0,0,0,85),(19,7,2,0,0,0,0,70),(20,8,2,0,0,0,0,74),(21,9,2,0,0,0,0,82),(22,10,2,0,0,0,0,77.5),(23,11,2,0,0,0,0,76.5),(24,12,2,0,0,0,0,81),(25,1,3,0,0,0,0,88),(26,2,3,0,0,0,0,89),(27,3,3,0,0,0,0,87),(28,4,3,0,0,0,0,90),(29,5,3,0,0,0,0,91),(30,6,3,0,0,0,0,95),(31,7,3,0,0,0,0,92),(32,8,3,0,0,0,0,90),(33,9,3,0,0,0,0,96),(34,10,3,0,0,0,0,95),(35,11,3,0,0,0,0,96),(36,12,3,0,0,0,0,94);

--
-- Temporary view structure for view `talent_rank_f`
--

/*!50001 DROP VIEW IF EXISTS `talent_rank_f`*/;
/*!50001 CREATE VIEW `talent_rank_f` AS SELECT 
 1 AS `id`,
 1 AS `number`,
 1 AS `fullname`,
 1 AS `j1_score`,
 1 AS `j1_rank`,
 1 AS `j2_score`,
 1 AS `j2_rank`,
 1 AS `j3_score`,
 1 AS `j3_rank`,
 1 AS `j4_score`,
 1 AS `j4_rank`,
 1 AS `j5_score`,
 1 AS `j5_rank`,
 1 AS `j6_score`,
 1 AS `j6_rank`,
 1 AS `j7_score`,
 1 AS `j7_rank`,
 1 AS `j8_score`,
 1 AS `j8_rank`,
 1 AS `j9_score`,
 1 AS `j9_rank`,
 1 AS `total_rank`*/;

--
-- Temporary view structure for view `talent_rank_m`
--

/*!50001 DROP VIEW IF EXISTS `talent_rank_m`*/;
/*!50001 CREATE VIEW `talent_rank_m` AS SELECT 
 1 AS `id`,
 1 AS `number`,
 1 AS `fullname`,
 1 AS `j1_score`,
 1 AS `j1_rank`,
 1 AS `j2_score`,
 1 AS `j2_rank`,
 1 AS `j3_score`,
 1 AS `j3_rank`,
 1 AS `j4_score`,
 1 AS `j4_rank`,
 1 AS `j5_score`,
 1 AS `j5_rank`,
 1 AS `j6_score`,
 1 AS `j6_rank`,
 1 AS `j7_score`,
 1 AS `j7_rank`,
 1 AS `j8_score`,
 1 AS `j8_rank`,
 1 AS `j9_score`,
 1 AS `j9_rank`,
 1 AS `total_rank`*/;

--
-- Table structure for table `total`
--

CREATE TABLE `total` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `candidate_id` int(11) NOT NULL,
  `judge_id` double NOT NULL,
  `criteria` int(11) NOT NULL,
  `total` double DEFAULT NULL,
  `rank` double DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `fk_total_candidates1_idx` (`candidate_id`),
  CONSTRAINT `fk_total_candidates1` FOREIGN KEY (`candidate_id`) REFERENCES `candidates` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `total`
--


--
-- Dumping events for database 'mrandmsjblf'
--

--
-- Dumping routines for database 'mrandmsjblf'
--
/*!50003 DROP FUNCTION IF EXISTS `FINALINTERVIEW_GETRANK_PERJUDGE` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `FINALINTERVIEW_GETRANK_PERJUDGE`(jid INTEGER, cid INTEGER, g INTEGER) RETURNS decimal(20,4)
BEGIN
	
    DECLARE rank DECIMAL(20,4);
	
    SELECT
		(((SUM((pn1.total < pn2.total)) + 1) + SUM((pn1.total <= pn2.total))) / 2) AS rank
	FROM final_interview pn1
	JOIN (SELECT f.* FROM final_interview f JOIN candidates s ON f.candidate_id=s.id WHERE s.gender=g ) pn2
	JOIN candidates c ON pn1.candidate_id=c.id
	WHERE pn1.judge_id=jid and pn2.judge_id=jid and c.gender=g and c.id=cid and c.finalist=1
	GROUP BY pn1.candidate_id LIMIT 1 INTO rank;
    
RETURN (IFNULL(rank,0));
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `FINALINTERVIEW_GETRANK_PERJUDGE_F` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `FINALINTERVIEW_GETRANK_PERJUDGE_F`(jid INTEGER, cid INTEGER, g INTEGER) RETURNS decimal(20,4)
BEGIN
	
    DECLARE rank DECIMAL(20,4);
	
    SELECT
		(((SUM((pn1.total < pn2.total)) + 1) + SUM((pn1.total <= pn2.total))) / 2) AS rank
	FROM final_interview pn1
	JOIN final_interview pn2
	JOIN candidates c ON pn1.candidate_id=c.id
	WHERE pn1.judge_id=jid and pn2.judge_id=jid and c.gender=g and c.id=cid and pn1.candidate_id IN (1,2,3,4,5,6) and pn2.candidate_id IN (1,2,3,4,5,6)
	GROUP BY pn1.candidate_id LIMIT 1 INTO rank;
    
RETURN (IFNULL(rank,0));
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `FINALINTERVIEW_GETRANK_PERJUDGE_M` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `FINALINTERVIEW_GETRANK_PERJUDGE_M`(jid INTEGER, cid INTEGER, g INTEGER) RETURNS decimal(20,4)
BEGIN
	
    DECLARE rank DECIMAL(20,4);
	
    SELECT
		(((SUM((pn1.total < pn2.total)) + 1) + SUM((pn1.total <= pn2.total))) / 2) AS rank
	FROM final_interview pn1
	JOIN final_interview pn2
	JOIN candidates c ON pn1.candidate_id=c.id
	WHERE pn1.judge_id=jid and pn2.judge_id=jid and c.gender=g and c.id=cid and pn1.candidate_id IN (7,8,9,10,11,12) and pn2.candidate_id IN (7,8,9,10,11,12)
	GROUP BY pn1.candidate_id LIMIT 1 INTO rank;
    
RETURN (IFNULL(rank,0));
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `FORMALWEAR_GETRANK_PERJUDGE` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `FORMALWEAR_GETRANK_PERJUDGE`(jid INTEGER, cid INTEGER, g INTEGER) RETURNS decimal(20,4)
BEGIN
	
    DECLARE rank DECIMAL(20,4);
	
    SELECT
		(((SUM((pn1.total < pn2.total)) + 1) + SUM((pn1.total <= pn2.total))) / 2) AS rank
	FROM formal_wear pn1
	JOIN (SELECT f.* FROM formal_wear f JOIN candidates s ON f.candidate_id=s.id WHERE s.gender=g ) pn2
	JOIN candidates c ON pn1.candidate_id=c.id
	WHERE pn1.judge_id=jid and pn2.judge_id=jid and c.gender=g and c.id=cid 
	GROUP BY pn1.candidate_id LIMIT 1 INTO rank;
    
RETURN (IFNULL(rank,0));
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `INTERVIEW_GETRANK_PERJUDGE` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `INTERVIEW_GETRANK_PERJUDGE`(jid INTEGER, cid INTEGER, g INTEGER) RETURNS decimal(20,4)
BEGIN
	
    DECLARE rank DECIMAL(20,4);
	
    SELECT
		(((SUM((pn1.total < pn2.total)) + 1) + SUM((pn1.total <= pn2.total))) / 2) AS rank
	FROM interview pn1
	JOIN (SELECT f.* FROM interview f JOIN candidates s ON f.candidate_id=s.id WHERE s.gender=g ) pn2
	JOIN candidates c ON pn1.candidate_id=c.id
	WHERE pn1.judge_id=jid and pn2.judge_id=jid and c.gender=g and c.id=cid 
	GROUP BY pn1.candidate_id LIMIT 1 INTO rank;
    
RETURN (IFNULL(rank,0));
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `NEWCRITERIA2_GETRANK_PERJUDGE` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `NEWCRITERIA2_GETRANK_PERJUDGE`(jid INTEGER, cid INTEGER, g INTEGER) RETURNS decimal(20,4)
BEGIN
	
    DECLARE rank DECIMAL(20,4);
	
    SELECT
		(((SUM((pn1.total < pn2.total)) + 1) + SUM((pn1.total <= pn2.total))) / 2) AS rank
	FROM new_criteria2 pn1
	JOIN (SELECT f.* FROM new_criteria2 f JOIN candidates s ON f.candidate_id=s.id WHERE s.gender=g ) pn2
	JOIN candidates c ON pn1.candidate_id=c.id
	WHERE pn1.judge_id=jid and pn2.judge_id=jid and c.gender=g and c.id=cid 
	GROUP BY pn1.candidate_id LIMIT 1 INTO rank;
    
RETURN (IFNULL(rank,0));
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `NEWCRITERIA_GETRANK_PERJUDGE` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `NEWCRITERIA_GETRANK_PERJUDGE`(jid INTEGER, cid INTEGER, g INTEGER) RETURNS decimal(20,4)
BEGIN
	
    DECLARE rank DECIMAL(20,4);
	
    SELECT
		(((SUM((pn1.total < pn2.total)) + 1) + SUM((pn1.total <= pn2.total))) / 2) AS rank
	FROM new_criteria pn1
	JOIN (SELECT f.* FROM new_criteria f JOIN candidates s ON f.candidate_id=s.id WHERE s.gender=g ) pn2
	JOIN candidates c ON pn1.candidate_id=c.id
	WHERE pn1.judge_id=jid and pn2.judge_id=jid and c.gender=g and c.id=cid 
	GROUP BY pn1.candidate_id LIMIT 1 INTO rank;
    
RETURN (IFNULL(rank,0));
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `PRODNUM_GETRANK_PERJUDGE` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `PRODNUM_GETRANK_PERJUDGE`(jid INTEGER, cid INTEGER, g INTEGER) RETURNS decimal(20,4)
BEGIN
	
    DECLARE rank DECIMAL(20,4);
	
    SELECT
		(((SUM((pn1.total < pn2.total)) + 1) + SUM((pn1.total <= pn2.total))) / 2) AS rank
	FROM prod_number pn1
	JOIN (SELECT f.* FROM prod_number f JOIN candidates s ON f.candidate_id=s.id WHERE s.gender=g ) pn2
	JOIN candidates c ON pn1.candidate_id=c.id
	WHERE pn1.judge_id=jid and pn2.judge_id=jid and c.gender=g and c.id=cid 
	GROUP BY pn1.candidate_id LIMIT 1 INTO rank;
    
RETURN (IFNULL(rank,0));
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `RANK_FINALINTERVIEW_F` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `RANK_FINALINTERVIEW_F`(cid INTEGER) RETURNS decimal(20,4)
BEGIN
    DECLARE rank DECIMAL(20,4);
	
    SELECT
		(((SUM((pn1.total_rank > pn2.total_rank)) + 1) + SUM((pn1.total_rank >= pn2.total_rank))) / 2) AS rank
	FROM final_interview_rank_f pn1
	JOIN final_interview_rank_f pn2
	JOIN candidates c ON pn1.id=c.id
	WHERE c.id=cid 
	GROUP BY pn1.id LIMIT 1 INTO rank;
    
RETURN (IFNULL(rank,0));
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `RANK_FINALINTERVIEW_M` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `RANK_FINALINTERVIEW_M`(cid INTEGER) RETURNS decimal(20,4)
BEGIN
    DECLARE rank DECIMAL(20,4);
	
    SELECT
		(((SUM((pn1.total_rank > pn2.total_rank)) + 1) + SUM((pn1.total_rank >= pn2.total_rank))) / 2) AS rank
	FROM final_interview_rank_m pn1
	JOIN final_interview_rank_m pn2
	JOIN candidates c ON pn1.id=c.id
	WHERE c.id=cid 
	GROUP BY pn1.id LIMIT 1 INTO rank;
    
RETURN (IFNULL(rank,0));
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `RANK_FORMALWEAR_F` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `RANK_FORMALWEAR_F`(cid INTEGER) RETURNS decimal(20,4)
BEGIN
    DECLARE rank DECIMAL(20,4);
	
    SELECT
		(((SUM((pn1.total_rank > pn2.total_rank)) + 1) + SUM((pn1.total_rank >= pn2.total_rank))) / 2) AS rank
	FROM formal_wear_rank_f pn1
	JOIN formal_wear_rank_f pn2
	JOIN candidates c ON pn1.id=c.id
	WHERE c.id=cid 
	GROUP BY pn1.id LIMIT 1 INTO rank;
    
RETURN (IFNULL(rank,0));
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `RANK_FORMALWEAR_M` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `RANK_FORMALWEAR_M`(cid INTEGER) RETURNS decimal(20,4)
BEGIN
    DECLARE rank DECIMAL(20,4);
	
    SELECT
		(((SUM((pn1.total_rank > pn2.total_rank)) + 1) + SUM((pn1.total_rank >= pn2.total_rank))) / 2) AS rank
	FROM formal_wear_rank_m pn1
	JOIN formal_wear_rank_m pn2
	JOIN candidates c ON pn1.id=c.id
	WHERE c.id=cid 
	GROUP BY pn1.id LIMIT 1 INTO rank;
    
RETURN (IFNULL(rank,0));
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `RANK_INTERVIEW_F` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `RANK_INTERVIEW_F`(cid INTEGER) RETURNS decimal(20,4)
BEGIN
    DECLARE rank DECIMAL(20,4);
	
    SELECT
		(((SUM((pn1.total_rank > pn2.total_rank)) + 1) + SUM((pn1.total_rank >= pn2.total_rank))) / 2) AS rank
	FROM interview_rank_f pn1
	JOIN interview_rank_f pn2
	JOIN candidates c ON pn1.id=c.id
	WHERE c.id=cid 
	GROUP BY pn1.id LIMIT 1 INTO rank;
    
RETURN (IFNULL(rank,0));
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `RANK_INTERVIEW_M` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `RANK_INTERVIEW_M`(cid INTEGER) RETURNS decimal(20,4)
BEGIN
    DECLARE rank DECIMAL(20,4);
	
    SELECT
		(((SUM((pn1.total_rank > pn2.total_rank)) + 1) + SUM((pn1.total_rank >= pn2.total_rank))) / 2) AS rank
	FROM interview_rank_m pn1
	JOIN interview_rank_m pn2
	JOIN candidates c ON pn1.id=c.id
	WHERE c.id=cid 
	GROUP BY pn1.id LIMIT 1 INTO rank;
    
RETURN (IFNULL(rank,0));
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `RANK_NEWCRITERIA2_F` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `RANK_NEWCRITERIA2_F`(cid INTEGER) RETURNS decimal(20,4)
BEGIN
    DECLARE rank DECIMAL(20,4);
	
    SELECT
		(((SUM((pn1.total_rank > pn2.total_rank)) + 1) + SUM((pn1.total_rank >= pn2.total_rank))) / 2) AS rank
	FROM new_criteria2_rank_f pn1
	JOIN new_criteria2_rank_f pn2
	JOIN candidates c ON pn1.id=c.id
	WHERE c.id=cid 
	GROUP BY pn1.id LIMIT 1 INTO rank;
    
RETURN (IFNULL(rank,0));
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `RANK_NEWCRITERIA2_M` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `RANK_NEWCRITERIA2_M`(cid INTEGER) RETURNS decimal(20,4)
BEGIN
    DECLARE rank DECIMAL(20,4);
	
    SELECT
		(((SUM((pn1.total_rank > pn2.total_rank)) + 1) + SUM((pn1.total_rank >= pn2.total_rank))) / 2) AS rank
	FROM new_criteria2_rank_m pn1
	JOIN new_criteria2_rank_m pn2
	JOIN candidates c ON pn1.id=c.id
	WHERE c.id=cid 
	GROUP BY pn1.id LIMIT 1 INTO rank;
    
RETURN (IFNULL(rank,0));
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `RANK_NEWCRITERIA_F` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `RANK_NEWCRITERIA_F`(cid INTEGER) RETURNS decimal(20,4)
BEGIN
    DECLARE rank DECIMAL(20,4);
	
    SELECT
		(((SUM((pn1.total_rank > pn2.total_rank)) + 1) + SUM((pn1.total_rank >= pn2.total_rank))) / 2) AS rank
	FROM new_criteria_rank_f pn1
	JOIN new_criteria_rank_f pn2
	JOIN candidates c ON pn1.id=c.id
	WHERE c.id=cid 
	GROUP BY pn1.id LIMIT 1 INTO rank;
    
RETURN (IFNULL(rank,0));
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `RANK_NEWCRITERIA_M` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `RANK_NEWCRITERIA_M`(cid INTEGER) RETURNS decimal(20,4)
BEGIN
    DECLARE rank DECIMAL(20,4);
	
    SELECT
		(((SUM((pn1.total_rank > pn2.total_rank)) + 1) + SUM((pn1.total_rank >= pn2.total_rank))) / 2) AS rank
	FROM new_criteria_rank_m pn1
	JOIN new_criteria_rank_m pn2
	JOIN candidates c ON pn1.id=c.id
	WHERE c.id=cid 
	GROUP BY pn1.id LIMIT 1 INTO rank;
    
RETURN (IFNULL(rank,0));
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `RANK_PRODNUMBER_F` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `RANK_PRODNUMBER_F`(cid INTEGER) RETURNS decimal(20,4)
BEGIN
    DECLARE rank DECIMAL(20,4);
	
    SELECT
		(((SUM((pn1.total_rank > pn2.total_rank)) + 1) + SUM((pn1.total_rank >= pn2.total_rank))) / 2) AS rank
	FROM prod_number_rank_f pn1
	JOIN prod_number_rank_f pn2
	JOIN candidates c ON pn1.id=c.id
	WHERE c.id=cid 
	GROUP BY pn1.id LIMIT 1 INTO rank;
    
RETURN (IFNULL(rank,0));
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `RANK_PRODNUMBER_M` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `RANK_PRODNUMBER_M`(cid INTEGER) RETURNS decimal(20,4)
BEGIN
    DECLARE rank DECIMAL(20,4);
	
    SELECT
		(((SUM((pn1.total_rank > pn2.total_rank)) + 1) + SUM((pn1.total_rank >= pn2.total_rank))) / 2) AS rank
	FROM prod_number_rank_m pn1
	JOIN prod_number_rank_m pn2
	JOIN candidates c ON pn1.id=c.id
	WHERE c.id=cid 
	GROUP BY pn1.id LIMIT 1 INTO rank;
    
RETURN (IFNULL(rank,0));
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `RANK_SWIMWEAR_F` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `RANK_SWIMWEAR_F`(cid INTEGER) RETURNS decimal(20,4)
BEGIN
    DECLARE rank DECIMAL(20,4);
	
    SELECT
		(((SUM((pn1.total_rank > pn2.total_rank)) + 1) + SUM((pn1.total_rank >= pn2.total_rank))) / 2) AS rank
	FROM swim_wear_rank_f pn1
	JOIN swim_wear_rank_f pn2
	JOIN candidates c ON pn1.id=c.id
	WHERE c.id=cid 
	GROUP BY pn1.id LIMIT 1 INTO rank;
    
RETURN (IFNULL(rank,0));
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `RANK_SWIMWEAR_M` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `RANK_SWIMWEAR_M`(cid INTEGER) RETURNS decimal(20,4)
BEGIN
    DECLARE rank DECIMAL(20,4);
	
    SELECT
		(((SUM((pn1.total_rank > pn2.total_rank)) + 1) + SUM((pn1.total_rank >= pn2.total_rank))) / 2) AS rank
	FROM swim_wear_rank_m pn1
	JOIN swim_wear_rank_m pn2
	JOIN candidates c ON pn1.id=c.id
	WHERE c.id=cid 
	GROUP BY pn1.id LIMIT 1 INTO rank;
    
RETURN (IFNULL(rank,0));
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `RANK_TALENT_F` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `RANK_TALENT_F`(cid INTEGER) RETURNS decimal(20,4)
BEGIN
    DECLARE rank DECIMAL(20,4);
	
    SELECT
		(((SUM((pn1.total_rank > pn2.total_rank)) + 1) + SUM((pn1.total_rank >= pn2.total_rank))) / 2) AS rank
	FROM talent_rank_f pn1
	JOIN talent_rank_f pn2
	JOIN candidates c ON pn1.id=c.id
	WHERE c.id=cid 
	GROUP BY pn1.id LIMIT 1 INTO rank;
    
RETURN (IFNULL(rank,0));
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `RANK_TALENT_M` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `RANK_TALENT_M`(cid INTEGER) RETURNS decimal(20,4)
BEGIN
    DECLARE rank DECIMAL(20,4);
	
    SELECT
		(((SUM((pn1.total_rank > pn2.total_rank)) + 1) + SUM((pn1.total_rank >= pn2.total_rank))) / 2) AS rank
	FROM talent_rank_m pn1
	JOIN talent_rank_m pn2
	JOIN candidates c ON pn1.id=c.id
	WHERE c.id=cid 
	GROUP BY pn1.id LIMIT 1 INTO rank;
    
RETURN (IFNULL(rank,0));
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `SWIMWEAR_GETRANK_PERJUDGE` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `SWIMWEAR_GETRANK_PERJUDGE`(jid INTEGER, cid INTEGER, g INTEGER) RETURNS decimal(20,4)
BEGIN
	
    DECLARE rank DECIMAL(20,4);
	
    SELECT
		(((SUM((pn1.total < pn2.total)) + 1) + SUM((pn1.total <= pn2.total))) / 2) AS rank
	FROM swim_wear pn1
	JOIN (SELECT f.* FROM swim_wear f JOIN candidates s ON f.candidate_id=s.id WHERE s.gender=g ) pn2
	JOIN candidates c ON pn1.candidate_id=c.id
	WHERE pn1.judge_id=jid and pn2.judge_id=jid and c.gender=g and c.id=cid 
	GROUP BY pn1.candidate_id LIMIT 1 INTO rank;
    
RETURN (IFNULL(rank,0));
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `TALENT_GETRANK_PERJUDGE` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `TALENT_GETRANK_PERJUDGE`(jid INTEGER, cid INTEGER, g INTEGER) RETURNS decimal(20,4)
BEGIN
	
    DECLARE rank DECIMAL(20,4);
	
    SELECT
		(((SUM((pn1.total < pn2.total)) + 1) + SUM((pn1.total <= pn2.total))) / 2) AS rank
	FROM talent pn1
	JOIN (SELECT f.* FROM talent f JOIN candidates s ON f.candidate_id=s.id WHERE s.gender=g ) pn2
	JOIN candidates c ON pn1.candidate_id=c.id
	WHERE pn1.judge_id=jid and pn2.judge_id=jid and c.gender=g and c.id=cid 
	GROUP BY pn1.candidate_id LIMIT 1 INTO rank;
    
RETURN (IFNULL(rank,0));
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `tabulation` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `tabulation`(IN g INTEGER)
BEGIN

IF(g=0) THEN

	SELECT 
		c.id,
		c.number,
		c.fullname,
		(SELECT 
				total_rank
			FROM
				prod_number_rank_f
			WHERE
				id = c.id) AS prodnum,
		(SELECT prodnum * .15) AS computed_produm,
		(SELECT 
				total_rank
			FROM
				swim_wear_rank_f
			WHERE
				id = c.id) AS swimwear,
		(SELECT swimwear * .15) AS computed_swimwear,
		(SELECT 
				total_rank
			FROM
				talent_rank_f
			WHERE
				id = c.id) AS talent,
		(SELECT talent * .20) AS computed_talent,
		(SELECT 
				total_rank
			FROM
				formal_wear_rank_f
			WHERE
				id = c.id) AS formalwear,
		(SELECT formalwear * .20) AS computed_formalwear,
		(SELECT 
				total_rank
			FROM
				interview_rank_f
			WHERE
				id = c.id) AS interview,
		(SELECT interview * .30) AS computed_interview,
		(SELECT computed_produm + computed_swimwear + computed_talent + computed_formalwear + computed_interview) AS computed_final
	FROM
		candidates c
	WHERE
		c.gender = 0
	ORDER BY computed_final ASC;

ELSEIF(g=1) THEN

	SELECT 
		c.id,
		c.number,
		c.fullname,
		(SELECT 
				total_rank
			FROM
				prod_number_rank_m
			WHERE
				id = c.id) AS prodnum,
		(SELECT prodnum * .15) AS computed_produm,
		(SELECT 
				total_rank
			FROM
				swim_wear_rank_m
			WHERE
				id = c.id) AS swimwear,
		(SELECT swimwear * .15) AS computed_swimwear,
		(SELECT 
				total_rank
			FROM
				talent_rank_m
			WHERE
				id = c.id) AS talent,
		(SELECT talent * .20) AS computed_talent,
		(SELECT 
				total_rank
			FROM
				formal_wear_rank_m
			WHERE
				id = c.id) AS formalwear,
		(SELECT formalwear * .20) AS computed_formalwear,
		(SELECT 
				total_rank
			FROM
				interview_rank_m
			WHERE
				id = c.id) AS interview,
		(SELECT interview * .30) AS computed_interview,
		(SELECT computed_produm + computed_swimwear + computed_talent + computed_formalwear + computed_interview) AS computed_final
	FROM
		candidates c
	WHERE
		c.gender = 1
	ORDER BY computed_final ASC;

END IF;

END ;;
DELIMITER ;

--
-- Final view structure for view `ave_final_interview`
--

/*!50001 DROP VIEW IF EXISTS `ave_final_interview`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `ave_final_interview` AS select `final_interview`.`candidate_id` AS `candidate_id`,`candidates`.`gender` AS `gender`,avg(`final_interview`.`total`) AS `ave` from (`final_interview` join `candidates`) where (`final_interview`.`candidate_id` = `candidates`.`id`) group by `final_interview`.`candidate_id` order by avg(`final_interview`.`total`) desc */;

--
-- Final view structure for view `ave_formal_wear`
--

/*!50001 DROP VIEW IF EXISTS `ave_formal_wear`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `ave_formal_wear` AS select `formal_wear`.`candidate_id` AS `candidate_id`,`candidates`.`gender` AS `gender`,avg(`formal_wear`.`total`) AS `ave` from (`formal_wear` join `candidates`) where (`formal_wear`.`candidate_id` = `candidates`.`id`) group by `formal_wear`.`candidate_id` order by avg(`formal_wear`.`total`) desc */;

--
-- Final view structure for view `ave_formal_wear_f`
--

/*!50001 DROP VIEW IF EXISTS `ave_formal_wear_f`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `ave_formal_wear_f` AS select `formal_wear`.`candidate_id` AS `candidate_id`,`candidates`.`fullname` AS `fullname`,`candidates`.`gender` AS `gender`,avg(`formal_wear`.`total`) AS `average`,`candidates`.`number` AS `number`,(select `formal_wear`.`total` from `formal_wear` where ((`formal_wear`.`judge_id` = 4) and (`formal_wear`.`candidate_id` = `candidates`.`id`))) AS `judge_1`,(select `formal_wear`.`total` from `formal_wear` where ((`formal_wear`.`judge_id` = 5) and (`formal_wear`.`candidate_id` = `candidates`.`id`))) AS `judge_2`,(select `formal_wear`.`total` from `formal_wear` where ((`formal_wear`.`judge_id` = 6) and (`formal_wear`.`candidate_id` = `candidates`.`id`))) AS `judge_3` from (`formal_wear` join `candidates`) where ((`formal_wear`.`candidate_id` = `candidates`.`id`) and (`candidates`.`gender` = 0)) group by `formal_wear`.`candidate_id` order by avg(`formal_wear`.`total`) desc */;

--
-- Final view structure for view `ave_formal_wear_m`
--

/*!50001 DROP VIEW IF EXISTS `ave_formal_wear_m`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `ave_formal_wear_m` AS select `formal_wear`.`candidate_id` AS `candidate_id`,`candidates`.`fullname` AS `fullname`,`candidates`.`gender` AS `gender`,avg(`formal_wear`.`total`) AS `average`,`candidates`.`number` AS `number`,(select `formal_wear`.`total` from `formal_wear` where ((`formal_wear`.`judge_id` = 1) and (`formal_wear`.`candidate_id` = `candidates`.`id`))) AS `judge_1`,(select `formal_wear`.`total` from `formal_wear` where ((`formal_wear`.`judge_id` = 2) and (`formal_wear`.`candidate_id` = `candidates`.`id`))) AS `judge_2`,(select `formal_wear`.`total` from `formal_wear` where ((`formal_wear`.`judge_id` = 3) and (`formal_wear`.`candidate_id` = `candidates`.`id`))) AS `judge_3` from (`formal_wear` join `candidates`) where ((`formal_wear`.`candidate_id` = `candidates`.`id`) and (`candidates`.`gender` = 1)) group by `formal_wear`.`candidate_id` order by avg(`formal_wear`.`total`) desc */;

--
-- Final view structure for view `ave_interview`
--

/*!50001 DROP VIEW IF EXISTS `ave_interview`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `ave_interview` AS select `interview`.`candidate_id` AS `candidate_id`,`candidates`.`gender` AS `gender`,avg(`interview`.`total`) AS `ave` from (`interview` join `candidates`) where (`interview`.`candidate_id` = `candidates`.`id`) group by `interview`.`candidate_id` order by avg(`interview`.`total`) desc */;

--
-- Final view structure for view `ave_interview_f`
--

/*!50001 DROP VIEW IF EXISTS `ave_interview_f`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `ave_interview_f` AS select `interview`.`candidate_id` AS `candidate_id`,`candidates`.`fullname` AS `fullname`,`candidates`.`gender` AS `gender`,avg(`interview`.`total`) AS `average`,`candidates`.`number` AS `number`,(select `interview`.`total` from `interview` where ((`interview`.`judge_id` = 4) and (`interview`.`candidate_id` = `candidates`.`id`))) AS `judge_1`,(select `interview`.`total` from `interview` where ((`interview`.`judge_id` = 5) and (`interview`.`candidate_id` = `candidates`.`id`))) AS `judge_2`,(select `interview`.`total` from `interview` where ((`interview`.`judge_id` = 6) and (`interview`.`candidate_id` = `candidates`.`id`))) AS `judge_3` from (`interview` join `candidates`) where ((`interview`.`candidate_id` = `candidates`.`id`) and (`candidates`.`gender` = 0)) group by `interview`.`candidate_id` order by avg(`interview`.`total`) desc */;

--
-- Final view structure for view `ave_interview_m`
--

/*!50001 DROP VIEW IF EXISTS `ave_interview_m`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `ave_interview_m` AS select `interview`.`candidate_id` AS `candidate_id`,`candidates`.`fullname` AS `fullname`,`candidates`.`gender` AS `gender`,avg(`interview`.`total`) AS `average`,`candidates`.`number` AS `number`,(select `interview`.`total` from `interview` where ((`interview`.`judge_id` = 1) and (`interview`.`candidate_id` = `candidates`.`id`))) AS `judge_1`,(select `interview`.`total` from `interview` where ((`interview`.`judge_id` = 2) and (`interview`.`candidate_id` = `candidates`.`id`))) AS `judge_2`,(select `interview`.`total` from `interview` where ((`interview`.`judge_id` = 3) and (`interview`.`candidate_id` = `candidates`.`id`))) AS `judge_3` from (`interview` join `candidates`) where ((`interview`.`candidate_id` = `candidates`.`id`) and (`candidates`.`gender` = 1)) group by `interview`.`candidate_id` order by avg(`interview`.`total`) desc */;

--
-- Final view structure for view `ave_new_criteria`
--

/*!50001 DROP VIEW IF EXISTS `ave_new_criteria`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `ave_new_criteria` AS select `new_criteria`.`candidate_id` AS `candidate_id`,`candidates`.`gender` AS `gender`,avg(`new_criteria`.`total`) AS `ave` from (`new_criteria` join `candidates`) where (`new_criteria`.`candidate_id` = `candidates`.`id`) group by `new_criteria`.`candidate_id` order by avg(`new_criteria`.`total`) desc */;

--
-- Final view structure for view `ave_prod_number`
--

/*!50001 DROP VIEW IF EXISTS `ave_prod_number`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `ave_prod_number` AS select `prod_number`.`candidate_id` AS `candidate_id`,`candidates`.`gender` AS `gender`,avg(`prod_number`.`total`) AS `ave` from (`prod_number` join `candidates`) where (`prod_number`.`candidate_id` = `candidates`.`id`) group by `prod_number`.`candidate_id` order by avg(`prod_number`.`total`) desc */;

--
-- Final view structure for view `ave_prodnumber_f`
--

/*!50001 DROP VIEW IF EXISTS `ave_prodnumber_f`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `ave_prodnumber_f` AS select `prod_number`.`candidate_id` AS `candidate_id`,`candidates`.`fullname` AS `fullname`,`candidates`.`gender` AS `gender`,avg(`prod_number`.`total`) AS `average`,`candidates`.`number` AS `number`,(select `prod_number`.`total` from `prod_number` where ((`prod_number`.`judge_id` = 4) and (`prod_number`.`candidate_id` = `candidates`.`id`))) AS `judge_1`,(select `prod_number`.`total` from `prod_number` where ((`prod_number`.`judge_id` = 5) and (`prod_number`.`candidate_id` = `candidates`.`id`))) AS `judge_2`,(select `prod_number`.`total` from `prod_number` where ((`prod_number`.`judge_id` = 6) and (`prod_number`.`candidate_id` = `candidates`.`id`))) AS `judge_3` from (`prod_number` join `candidates`) where ((`prod_number`.`candidate_id` = `candidates`.`id`) and (`candidates`.`gender` = 0)) group by `prod_number`.`candidate_id` order by avg(`prod_number`.`total`) desc */;

--
-- Final view structure for view `ave_prodnumber_m`
--

/*!50001 DROP VIEW IF EXISTS `ave_prodnumber_m`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `ave_prodnumber_m` AS select `prod_number`.`candidate_id` AS `candidate_id`,`candidates`.`fullname` AS `fullname`,`candidates`.`gender` AS `gender`,avg(`prod_number`.`total`) AS `average`,`candidates`.`number` AS `number`,(select `prod_number`.`total` from `prod_number` where ((`prod_number`.`judge_id` = 1) and (`prod_number`.`candidate_id` = `candidates`.`id`))) AS `judge_1`,(select `prod_number`.`total` from `prod_number` where ((`prod_number`.`judge_id` = 2) and (`prod_number`.`candidate_id` = `candidates`.`id`))) AS `judge_2`,(select `prod_number`.`total` from `prod_number` where ((`prod_number`.`judge_id` = 3) and (`prod_number`.`candidate_id` = `candidates`.`id`))) AS `judge_3` from (`prod_number` join `candidates`) where ((`prod_number`.`candidate_id` = `candidates`.`id`) and (`candidates`.`gender` = 1)) group by `prod_number`.`candidate_id` order by avg(`prod_number`.`total`) desc */;

--
-- Final view structure for view `ave_swim_wear`
--

/*!50001 DROP VIEW IF EXISTS `ave_swim_wear`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `ave_swim_wear` AS select `swim_wear`.`candidate_id` AS `candidate_id`,`candidates`.`gender` AS `gender`,avg(`swim_wear`.`total`) AS `ave` from (`swim_wear` join `candidates`) where (`swim_wear`.`candidate_id` = `candidates`.`id`) group by `swim_wear`.`candidate_id` order by avg(`swim_wear`.`total`) desc */;

--
-- Final view structure for view `ave_swimwear_f`
--

/*!50001 DROP VIEW IF EXISTS `ave_swimwear_f`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `ave_swimwear_f` AS select `swim_wear`.`candidate_id` AS `candidate_id`,`candidates`.`fullname` AS `fullname`,`candidates`.`gender` AS `gender`,avg(`swim_wear`.`total`) AS `average`,`candidates`.`number` AS `number`,(select `swim_wear`.`total` from `swim_wear` where ((`swim_wear`.`judge_id` = 4) and (`swim_wear`.`candidate_id` = `candidates`.`id`))) AS `judge_1`,(select `swim_wear`.`total` from `swim_wear` where ((`swim_wear`.`judge_id` = 5) and (`swim_wear`.`candidate_id` = `candidates`.`id`))) AS `judge_2`,(select `swim_wear`.`total` from `swim_wear` where ((`swim_wear`.`judge_id` = 6) and (`swim_wear`.`candidate_id` = `candidates`.`id`))) AS `judge_3` from (`swim_wear` join `candidates`) where ((`swim_wear`.`candidate_id` = `candidates`.`id`) and (`candidates`.`gender` = 0)) group by `swim_wear`.`candidate_id` order by avg(`swim_wear`.`total`) desc */;

--
-- Final view structure for view `ave_swimwear_m`
--

/*!50001 DROP VIEW IF EXISTS `ave_swimwear_m`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `ave_swimwear_m` AS select `swim_wear`.`candidate_id` AS `candidate_id`,`candidates`.`fullname` AS `fullname`,`candidates`.`gender` AS `gender`,avg(`swim_wear`.`total`) AS `average`,`candidates`.`number` AS `number`,(select `swim_wear`.`total` from `swim_wear` where ((`swim_wear`.`judge_id` = 1) and (`swim_wear`.`candidate_id` = `candidates`.`id`))) AS `judge_1`,(select `swim_wear`.`total` from `swim_wear` where ((`swim_wear`.`judge_id` = 2) and (`swim_wear`.`candidate_id` = `candidates`.`id`))) AS `judge_2`,(select `swim_wear`.`total` from `swim_wear` where ((`swim_wear`.`judge_id` = 3) and (`swim_wear`.`candidate_id` = `candidates`.`id`))) AS `judge_3` from (`swim_wear` join `candidates`) where ((`swim_wear`.`candidate_id` = `candidates`.`id`) and (`candidates`.`gender` = 1)) group by `swim_wear`.`candidate_id` order by avg(`swim_wear`.`total`) desc */;

--
-- Final view structure for view `ave_talent`
--

/*!50001 DROP VIEW IF EXISTS `ave_talent`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `ave_talent` AS select `talent`.`candidate_id` AS `candidate_id`,`candidates`.`gender` AS `gender`,avg(`talent`.`total`) AS `ave` from (`talent` join `candidates`) where (`talent`.`candidate_id` = `candidates`.`id`) group by `talent`.`candidate_id` order by avg(`talent`.`total`) desc */;

--
-- Final view structure for view `ave_talent_f`
--

/*!50001 DROP VIEW IF EXISTS `ave_talent_f`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `ave_talent_f` AS select `talent`.`candidate_id` AS `candidate_id`,`candidates`.`fullname` AS `fullname`,`candidates`.`gender` AS `gender`,avg(`talent`.`total`) AS `average`,`candidates`.`number` AS `number`,(select `talent`.`total` from `talent` where ((`talent`.`judge_id` = 4) and (`talent`.`candidate_id` = `candidates`.`id`))) AS `judge_1`,(select `talent`.`total` from `talent` where ((`talent`.`judge_id` = 5) and (`talent`.`candidate_id` = `candidates`.`id`))) AS `judge_2`,(select `talent`.`total` from `talent` where ((`talent`.`judge_id` = 6) and (`talent`.`candidate_id` = `candidates`.`id`))) AS `judge_3` from (`talent` join `candidates`) where ((`talent`.`candidate_id` = `candidates`.`id`) and (`candidates`.`gender` = 0)) group by `talent`.`candidate_id` order by avg(`talent`.`total`) desc */;

--
-- Final view structure for view `ave_talent_m`
--

/*!50001 DROP VIEW IF EXISTS `ave_talent_m`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `ave_talent_m` AS select `talent`.`candidate_id` AS `candidate_id`,`candidates`.`fullname` AS `fullname`,`candidates`.`gender` AS `gender`,avg(`talent`.`total`) AS `average`,`candidates`.`number` AS `number`,(select `talent`.`total` from `talent` where ((`talent`.`judge_id` = 1) and (`talent`.`candidate_id` = `candidates`.`id`))) AS `judge_1`,(select `talent`.`total` from `talent` where ((`talent`.`judge_id` = 2) and (`talent`.`candidate_id` = `candidates`.`id`))) AS `judge_2`,(select `talent`.`total` from `talent` where ((`talent`.`judge_id` = 3) and (`talent`.`candidate_id` = `candidates`.`id`))) AS `judge_3` from (`talent` join `candidates`) where ((`talent`.`candidate_id` = `candidates`.`id`) and (`candidates`.`gender` = 1)) group by `talent`.`candidate_id` order by avg(`talent`.`total`) desc */;

--
-- Final view structure for view `final_interview_rank_f`
--

/*!50001 DROP VIEW IF EXISTS `final_interview_rank_f`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `final_interview_rank_f` AS select `c`.`id` AS `id`,`c`.`number` AS `number`,`c`.`fullname` AS `fullname`,(select `final_interview`.`total` from `final_interview` where ((`final_interview`.`candidate_id` = `c`.`id`) and (`final_interview`.`judge_id` = 1))) AS `j1_score`,(select `FINALINTERVIEW_GETRANK_PERJUDGE`(1,`c`.`id`,`c`.`gender`)) AS `j1_rank`,(select `final_interview`.`total` from `final_interview` where ((`final_interview`.`candidate_id` = `c`.`id`) and (`final_interview`.`judge_id` = 2))) AS `j2_score`,(select `FINALINTERVIEW_GETRANK_PERJUDGE`(2,`c`.`id`,`c`.`gender`)) AS `j2_rank`,(select `final_interview`.`total` from `final_interview` where ((`final_interview`.`candidate_id` = `c`.`id`) and (`final_interview`.`judge_id` = 3))) AS `j3_score`,(select `FINALINTERVIEW_GETRANK_PERJUDGE`(3,`c`.`id`,`c`.`gender`)) AS `j3_rank`,(select `final_interview`.`total` from `final_interview` where ((`final_interview`.`candidate_id` = `c`.`id`) and (`final_interview`.`judge_id` = 4))) AS `j4_score`,(select `FINALINTERVIEW_GETRANK_PERJUDGE`(4,`c`.`id`,`c`.`gender`)) AS `j4_rank`,(select `final_interview`.`total` from `final_interview` where ((`final_interview`.`candidate_id` = `c`.`id`) and (`final_interview`.`judge_id` = 5))) AS `j5_score`,(select `FINALINTERVIEW_GETRANK_PERJUDGE`(5,`c`.`id`,`c`.`gender`)) AS `j5_rank`,(select `final_interview`.`total` from `final_interview` where ((`final_interview`.`candidate_id` = `c`.`id`) and (`final_interview`.`judge_id` = 6))) AS `j6_score`,(select `FINALINTERVIEW_GETRANK_PERJUDGE`(6,`c`.`id`,`c`.`gender`)) AS `j6_rank`,(select `final_interview`.`total` from `final_interview` where ((`final_interview`.`candidate_id` = `c`.`id`) and (`final_interview`.`judge_id` = 7))) AS `j7_score`,(select `FINALINTERVIEW_GETRANK_PERJUDGE`(7,`c`.`id`,`c`.`gender`)) AS `j7_rank`,(select `final_interview`.`total` from `final_interview` where ((`final_interview`.`candidate_id` = `c`.`id`) and (`final_interview`.`judge_id` = 8))) AS `j8_score`,(select `FINALINTERVIEW_GETRANK_PERJUDGE`(8,`c`.`id`,`c`.`gender`)) AS `j8_rank`,(select `final_interview`.`total` from `final_interview` where ((`final_interview`.`candidate_id` = `c`.`id`) and (`final_interview`.`judge_id` = 9))) AS `j9_score`,(select `FINALINTERVIEW_GETRANK_PERJUDGE`(9,`c`.`id`,`c`.`gender`)) AS `j9_rank`,(((((((((select `j1_rank`) + (select `j2_rank`)) + (select `j3_rank`)) + (select `j4_rank`)) + (select `j5_rank`)) + (select `j6_rank`)) + (select `j7_rank`)) + (select `j8_rank`)) + (select `j9_rank`)) AS `total_rank` from `candidates` `c` where ((`c`.`gender` = 0) and (`c`.`finalist` = 1)) */;

--
-- Final view structure for view `final_interview_rank_m`
--

/*!50001 DROP VIEW IF EXISTS `final_interview_rank_m`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `final_interview_rank_m` AS select `c`.`id` AS `id`,`c`.`number` AS `number`,`c`.`fullname` AS `fullname`,(select `final_interview`.`total` from `final_interview` where ((`final_interview`.`candidate_id` = `c`.`id`) and (`final_interview`.`judge_id` = 1))) AS `j1_score`,(select `FINALINTERVIEW_GETRANK_PERJUDGE`(1,`c`.`id`,`c`.`gender`)) AS `j1_rank`,(select `final_interview`.`total` from `final_interview` where ((`final_interview`.`candidate_id` = `c`.`id`) and (`final_interview`.`judge_id` = 2))) AS `j2_score`,(select `FINALINTERVIEW_GETRANK_PERJUDGE`(2,`c`.`id`,`c`.`gender`)) AS `j2_rank`,(select `final_interview`.`total` from `final_interview` where ((`final_interview`.`candidate_id` = `c`.`id`) and (`final_interview`.`judge_id` = 3))) AS `j3_score`,(select `FINALINTERVIEW_GETRANK_PERJUDGE`(3,`c`.`id`,`c`.`gender`)) AS `j3_rank`,(select `final_interview`.`total` from `final_interview` where ((`final_interview`.`candidate_id` = `c`.`id`) and (`final_interview`.`judge_id` = 4))) AS `j4_score`,(select `FINALINTERVIEW_GETRANK_PERJUDGE`(4,`c`.`id`,`c`.`gender`)) AS `j4_rank`,(select `final_interview`.`total` from `final_interview` where ((`final_interview`.`candidate_id` = `c`.`id`) and (`final_interview`.`judge_id` = 5))) AS `j5_score`,(select `FINALINTERVIEW_GETRANK_PERJUDGE`(5,`c`.`id`,`c`.`gender`)) AS `j5_rank`,(select `final_interview`.`total` from `final_interview` where ((`final_interview`.`candidate_id` = `c`.`id`) and (`final_interview`.`judge_id` = 6))) AS `j6_score`,(select `FINALINTERVIEW_GETRANK_PERJUDGE`(6,`c`.`id`,`c`.`gender`)) AS `j6_rank`,(select `final_interview`.`total` from `final_interview` where ((`final_interview`.`candidate_id` = `c`.`id`) and (`final_interview`.`judge_id` = 7))) AS `j7_score`,(select `FINALINTERVIEW_GETRANK_PERJUDGE`(7,`c`.`id`,`c`.`gender`)) AS `j7_rank`,(select `final_interview`.`total` from `final_interview` where ((`final_interview`.`candidate_id` = `c`.`id`) and (`final_interview`.`judge_id` = 8))) AS `j8_score`,(select `FINALINTERVIEW_GETRANK_PERJUDGE`(8,`c`.`id`,`c`.`gender`)) AS `j8_rank`,(select `final_interview`.`total` from `final_interview` where ((`final_interview`.`candidate_id` = `c`.`id`) and (`final_interview`.`judge_id` = 9))) AS `j9_score`,(select `FINALINTERVIEW_GETRANK_PERJUDGE`(9,`c`.`id`,`c`.`gender`)) AS `j9_rank`,(((((((((select `j1_rank`) + (select `j2_rank`)) + (select `j3_rank`)) + (select `j4_rank`)) + (select `j5_rank`)) + (select `j6_rank`)) + (select `j7_rank`)) + (select `j8_rank`)) + (select `j9_rank`)) AS `total_rank` from `candidates` `c` where ((`c`.`gender` = 1) and (`c`.`finalist` = 1)) */;

--
-- Final view structure for view `formal_wear_rank_f`
--

/*!50001 DROP VIEW IF EXISTS `formal_wear_rank_f`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `formal_wear_rank_f` AS select `c`.`id` AS `id`,`c`.`number` AS `number`,`c`.`fullname` AS `fullname`,(select `formal_wear`.`total` from `formal_wear` where ((`formal_wear`.`candidate_id` = `c`.`id`) and (`formal_wear`.`judge_id` = 1))) AS `j1_score`,(select `FORMALWEAR_GETRANK_PERJUDGE`(1,`c`.`id`,`c`.`gender`)) AS `j1_rank`,(select `formal_wear`.`total` from `formal_wear` where ((`formal_wear`.`candidate_id` = `c`.`id`) and (`formal_wear`.`judge_id` = 2))) AS `j2_score`,(select `FORMALWEAR_GETRANK_PERJUDGE`(2,`c`.`id`,`c`.`gender`)) AS `j2_rank`,(select `formal_wear`.`total` from `formal_wear` where ((`formal_wear`.`candidate_id` = `c`.`id`) and (`formal_wear`.`judge_id` = 3))) AS `j3_score`,(select `FORMALWEAR_GETRANK_PERJUDGE`(3,`c`.`id`,`c`.`gender`)) AS `j3_rank`,(select `formal_wear`.`total` from `formal_wear` where ((`formal_wear`.`candidate_id` = `c`.`id`) and (`formal_wear`.`judge_id` = 4))) AS `j4_score`,(select `FORMALWEAR_GETRANK_PERJUDGE`(4,`c`.`id`,`c`.`gender`)) AS `j4_rank`,(select `formal_wear`.`total` from `formal_wear` where ((`formal_wear`.`candidate_id` = `c`.`id`) and (`formal_wear`.`judge_id` = 5))) AS `j5_score`,(select `FORMALWEAR_GETRANK_PERJUDGE`(5,`c`.`id`,`c`.`gender`)) AS `j5_rank`,(select `formal_wear`.`total` from `formal_wear` where ((`formal_wear`.`candidate_id` = `c`.`id`) and (`formal_wear`.`judge_id` = 6))) AS `j6_score`,(select `FORMALWEAR_GETRANK_PERJUDGE`(6,`c`.`id`,`c`.`gender`)) AS `j6_rank`,(select `formal_wear`.`total` from `formal_wear` where ((`formal_wear`.`candidate_id` = `c`.`id`) and (`formal_wear`.`judge_id` = 7))) AS `j7_score`,(select `FORMALWEAR_GETRANK_PERJUDGE`(7,`c`.`id`,`c`.`gender`)) AS `j7_rank`,(select `formal_wear`.`total` from `formal_wear` where ((`formal_wear`.`candidate_id` = `c`.`id`) and (`formal_wear`.`judge_id` = 8))) AS `j8_score`,(select `FORMALWEAR_GETRANK_PERJUDGE`(8,`c`.`id`,`c`.`gender`)) AS `j8_rank`,(select `formal_wear`.`total` from `formal_wear` where ((`formal_wear`.`candidate_id` = `c`.`id`) and (`formal_wear`.`judge_id` = 9))) AS `j9_score`,(select `FORMALWEAR_GETRANK_PERJUDGE`(9,`c`.`id`,`c`.`gender`)) AS `j9_rank`,(((((((((select `j1_rank`) + (select `j2_rank`)) + (select `j3_rank`)) + (select `j4_rank`)) + (select `j5_rank`)) + (select `j6_rank`)) + (select `j7_rank`)) + (select `j8_rank`)) + (select `j9_rank`)) AS `total_rank` from `candidates` `c` where (`c`.`gender` = 0) */;

--
-- Final view structure for view `formal_wear_rank_m`
--

/*!50001 DROP VIEW IF EXISTS `formal_wear_rank_m`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `formal_wear_rank_m` AS select `c`.`id` AS `id`,`c`.`number` AS `number`,`c`.`fullname` AS `fullname`,(select `formal_wear`.`total` from `formal_wear` where ((`formal_wear`.`candidate_id` = `c`.`id`) and (`formal_wear`.`judge_id` = 1))) AS `j1_score`,(select `FORMALWEAR_GETRANK_PERJUDGE`(1,`c`.`id`,`c`.`gender`)) AS `j1_rank`,(select `formal_wear`.`total` from `formal_wear` where ((`formal_wear`.`candidate_id` = `c`.`id`) and (`formal_wear`.`judge_id` = 2))) AS `j2_score`,(select `FORMALWEAR_GETRANK_PERJUDGE`(2,`c`.`id`,`c`.`gender`)) AS `j2_rank`,(select `formal_wear`.`total` from `formal_wear` where ((`formal_wear`.`candidate_id` = `c`.`id`) and (`formal_wear`.`judge_id` = 3))) AS `j3_score`,(select `FORMALWEAR_GETRANK_PERJUDGE`(3,`c`.`id`,`c`.`gender`)) AS `j3_rank`,(select `formal_wear`.`total` from `formal_wear` where ((`formal_wear`.`candidate_id` = `c`.`id`) and (`formal_wear`.`judge_id` = 4))) AS `j4_score`,(select `FORMALWEAR_GETRANK_PERJUDGE`(4,`c`.`id`,`c`.`gender`)) AS `j4_rank`,(select `formal_wear`.`total` from `formal_wear` where ((`formal_wear`.`candidate_id` = `c`.`id`) and (`formal_wear`.`judge_id` = 5))) AS `j5_score`,(select `FORMALWEAR_GETRANK_PERJUDGE`(5,`c`.`id`,`c`.`gender`)) AS `j5_rank`,(select `formal_wear`.`total` from `formal_wear` where ((`formal_wear`.`candidate_id` = `c`.`id`) and (`formal_wear`.`judge_id` = 6))) AS `j6_score`,(select `FORMALWEAR_GETRANK_PERJUDGE`(6,`c`.`id`,`c`.`gender`)) AS `j6_rank`,(select `formal_wear`.`total` from `formal_wear` where ((`formal_wear`.`candidate_id` = `c`.`id`) and (`formal_wear`.`judge_id` = 7))) AS `j7_score`,(select `FORMALWEAR_GETRANK_PERJUDGE`(7,`c`.`id`,`c`.`gender`)) AS `j7_rank`,(select `formal_wear`.`total` from `formal_wear` where ((`formal_wear`.`candidate_id` = `c`.`id`) and (`formal_wear`.`judge_id` = 8))) AS `j8_score`,(select `FORMALWEAR_GETRANK_PERJUDGE`(8,`c`.`id`,`c`.`gender`)) AS `j8_rank`,(select `formal_wear`.`total` from `formal_wear` where ((`formal_wear`.`candidate_id` = `c`.`id`) and (`formal_wear`.`judge_id` = 9))) AS `j9_score`,(select `FORMALWEAR_GETRANK_PERJUDGE`(9,`c`.`id`,`c`.`gender`)) AS `j9_rank`,(((((((((select `j1_rank`) + (select `j2_rank`)) + (select `j3_rank`)) + (select `j4_rank`)) + (select `j5_rank`)) + (select `j6_rank`)) + (select `j7_rank`)) + (select `j8_rank`)) + (select `j9_rank`)) AS `total_rank` from `candidates` `c` where (`c`.`gender` = 1) */;

--
-- Final view structure for view `interview_rank_f`
--

/*!50001 DROP VIEW IF EXISTS `interview_rank_f`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `interview_rank_f` AS select `c`.`id` AS `id`,`c`.`number` AS `number`,`c`.`fullname` AS `fullname`,(select `interview`.`total` from `interview` where ((`interview`.`candidate_id` = `c`.`id`) and (`interview`.`judge_id` = 1))) AS `j1_score`,(select `INTERVIEW_GETRANK_PERJUDGE`(1,`c`.`id`,`c`.`gender`)) AS `j1_rank`,(select `interview`.`total` from `interview` where ((`interview`.`candidate_id` = `c`.`id`) and (`interview`.`judge_id` = 2))) AS `j2_score`,(select `INTERVIEW_GETRANK_PERJUDGE`(2,`c`.`id`,`c`.`gender`)) AS `j2_rank`,(select `interview`.`total` from `interview` where ((`interview`.`candidate_id` = `c`.`id`) and (`interview`.`judge_id` = 3))) AS `j3_score`,(select `INTERVIEW_GETRANK_PERJUDGE`(3,`c`.`id`,`c`.`gender`)) AS `j3_rank`,(select `interview`.`total` from `interview` where ((`interview`.`candidate_id` = `c`.`id`) and (`interview`.`judge_id` = 4))) AS `j4_score`,(select `INTERVIEW_GETRANK_PERJUDGE`(4,`c`.`id`,`c`.`gender`)) AS `j4_rank`,(select `interview`.`total` from `interview` where ((`interview`.`candidate_id` = `c`.`id`) and (`interview`.`judge_id` = 5))) AS `j5_score`,(select `INTERVIEW_GETRANK_PERJUDGE`(5,`c`.`id`,`c`.`gender`)) AS `j5_rank`,(select `interview`.`total` from `interview` where ((`interview`.`candidate_id` = `c`.`id`) and (`interview`.`judge_id` = 6))) AS `j6_score`,(select `INTERVIEW_GETRANK_PERJUDGE`(6,`c`.`id`,`c`.`gender`)) AS `j6_rank`,(select `interview`.`total` from `interview` where ((`interview`.`candidate_id` = `c`.`id`) and (`interview`.`judge_id` = 7))) AS `j7_score`,(select `INTERVIEW_GETRANK_PERJUDGE`(7,`c`.`id`,`c`.`gender`)) AS `j7_rank`,(select `interview`.`total` from `interview` where ((`interview`.`candidate_id` = `c`.`id`) and (`interview`.`judge_id` = 8))) AS `j8_score`,(select `INTERVIEW_GETRANK_PERJUDGE`(8,`c`.`id`,`c`.`gender`)) AS `j8_rank`,(select `interview`.`total` from `interview` where ((`interview`.`candidate_id` = `c`.`id`) and (`interview`.`judge_id` = 9))) AS `j9_score`,(select `INTERVIEW_GETRANK_PERJUDGE`(9,`c`.`id`,`c`.`gender`)) AS `j9_rank`,(((((((((select `j1_rank`) + (select `j2_rank`)) + (select `j3_rank`)) + (select `j4_rank`)) + (select `j5_rank`)) + (select `j6_rank`)) + (select `j7_rank`)) + (select `j8_rank`)) + (select `j9_rank`)) AS `total_rank` from `candidates` `c` where (`c`.`gender` = 0) */;

--
-- Final view structure for view `interview_rank_m`
--

/*!50001 DROP VIEW IF EXISTS `interview_rank_m`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `interview_rank_m` AS select `c`.`id` AS `id`,`c`.`number` AS `number`,`c`.`fullname` AS `fullname`,(select `interview`.`total` from `interview` where ((`interview`.`candidate_id` = `c`.`id`) and (`interview`.`judge_id` = 1))) AS `j1_score`,(select `INTERVIEW_GETRANK_PERJUDGE`(1,`c`.`id`,`c`.`gender`)) AS `j1_rank`,(select `interview`.`total` from `interview` where ((`interview`.`candidate_id` = `c`.`id`) and (`interview`.`judge_id` = 2))) AS `j2_score`,(select `INTERVIEW_GETRANK_PERJUDGE`(2,`c`.`id`,`c`.`gender`)) AS `j2_rank`,(select `interview`.`total` from `interview` where ((`interview`.`candidate_id` = `c`.`id`) and (`interview`.`judge_id` = 3))) AS `j3_score`,(select `INTERVIEW_GETRANK_PERJUDGE`(3,`c`.`id`,`c`.`gender`)) AS `j3_rank`,(select `interview`.`total` from `interview` where ((`interview`.`candidate_id` = `c`.`id`) and (`interview`.`judge_id` = 4))) AS `j4_score`,(select `INTERVIEW_GETRANK_PERJUDGE`(4,`c`.`id`,`c`.`gender`)) AS `j4_rank`,(select `interview`.`total` from `interview` where ((`interview`.`candidate_id` = `c`.`id`) and (`interview`.`judge_id` = 5))) AS `j5_score`,(select `INTERVIEW_GETRANK_PERJUDGE`(5,`c`.`id`,`c`.`gender`)) AS `j5_rank`,(select `interview`.`total` from `interview` where ((`interview`.`candidate_id` = `c`.`id`) and (`interview`.`judge_id` = 6))) AS `j6_score`,(select `INTERVIEW_GETRANK_PERJUDGE`(6,`c`.`id`,`c`.`gender`)) AS `j6_rank`,(select `interview`.`total` from `interview` where ((`interview`.`candidate_id` = `c`.`id`) and (`interview`.`judge_id` = 7))) AS `j7_score`,(select `INTERVIEW_GETRANK_PERJUDGE`(7,`c`.`id`,`c`.`gender`)) AS `j7_rank`,(select `interview`.`total` from `interview` where ((`interview`.`candidate_id` = `c`.`id`) and (`interview`.`judge_id` = 8))) AS `j8_score`,(select `INTERVIEW_GETRANK_PERJUDGE`(8,`c`.`id`,`c`.`gender`)) AS `j8_rank`,(select `interview`.`total` from `interview` where ((`interview`.`candidate_id` = `c`.`id`) and (`interview`.`judge_id` = 9))) AS `j9_score`,(select `INTERVIEW_GETRANK_PERJUDGE`(9,`c`.`id`,`c`.`gender`)) AS `j9_rank`,(((((((((select `j1_rank`) + (select `j2_rank`)) + (select `j3_rank`)) + (select `j4_rank`)) + (select `j5_rank`)) + (select `j6_rank`)) + (select `j7_rank`)) + (select `j8_rank`)) + (select `j9_rank`)) AS `total_rank` from `candidates` `c` where (`c`.`gender` = 1) */;

--
-- Final view structure for view `new_criteria2_rank_f`
--

/*!50001 DROP VIEW IF EXISTS `new_criteria2_rank_f`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `new_criteria2_rank_f` AS select `c`.`id` AS `id`,`c`.`number` AS `number`,`c`.`fullname` AS `fullname`,(select `new_criteria2`.`total` from `new_criteria2` where ((`new_criteria2`.`candidate_id` = `c`.`id`) and (`new_criteria2`.`judge_id` = 1))) AS `j1_score`,(select `NEWCRITERIA2_GETRANK_PERJUDGE`(1,`c`.`id`,`c`.`gender`)) AS `j1_rank`,(select `new_criteria2`.`total` from `new_criteria2` where ((`new_criteria2`.`candidate_id` = `c`.`id`) and (`new_criteria2`.`judge_id` = 2))) AS `j2_score`,(select `NEWCRITERIA2_GETRANK_PERJUDGE`(2,`c`.`id`,`c`.`gender`)) AS `j2_rank`,(select `new_criteria2`.`total` from `new_criteria2` where ((`new_criteria2`.`candidate_id` = `c`.`id`) and (`new_criteria2`.`judge_id` = 3))) AS `j3_score`,(select `NEWCRITERIA2_GETRANK_PERJUDGE`(3,`c`.`id`,`c`.`gender`)) AS `j3_rank`,(select `new_criteria2`.`total` from `new_criteria2` where ((`new_criteria2`.`candidate_id` = `c`.`id`) and (`new_criteria2`.`judge_id` = 4))) AS `j4_score`,(select `NEWCRITERIA2_GETRANK_PERJUDGE`(4,`c`.`id`,`c`.`gender`)) AS `j4_rank`,(select `new_criteria2`.`total` from `new_criteria2` where ((`new_criteria2`.`candidate_id` = `c`.`id`) and (`new_criteria2`.`judge_id` = 5))) AS `j5_score`,(select `NEWCRITERIA2_GETRANK_PERJUDGE`(5,`c`.`id`,`c`.`gender`)) AS `j5_rank`,(select `new_criteria2`.`total` from `new_criteria2` where ((`new_criteria2`.`candidate_id` = `c`.`id`) and (`new_criteria2`.`judge_id` = 6))) AS `j6_score`,(select `NEWCRITERIA2_GETRANK_PERJUDGE`(6,`c`.`id`,`c`.`gender`)) AS `j6_rank`,(select `new_criteria2`.`total` from `new_criteria2` where ((`new_criteria2`.`candidate_id` = `c`.`id`) and (`new_criteria2`.`judge_id` = 7))) AS `j7_score`,(select `NEWCRITERIA2_GETRANK_PERJUDGE`(7,`c`.`id`,`c`.`gender`)) AS `j7_rank`,(select `new_criteria2`.`total` from `new_criteria2` where ((`new_criteria2`.`candidate_id` = `c`.`id`) and (`new_criteria2`.`judge_id` = 8))) AS `j8_score`,(select `NEWCRITERIA2_GETRANK_PERJUDGE`(8,`c`.`id`,`c`.`gender`)) AS `j8_rank`,(select `new_criteria2`.`total` from `new_criteria2` where ((`new_criteria2`.`candidate_id` = `c`.`id`) and (`new_criteria2`.`judge_id` = 9))) AS `j9_score`,(select `NEWCRITERIA2_GETRANK_PERJUDGE`(9,`c`.`id`,`c`.`gender`)) AS `j9_rank`,(((((((((select `j1_rank`) + (select `j2_rank`)) + (select `j3_rank`)) + (select `j4_rank`)) + (select `j5_rank`)) + (select `j6_rank`)) + (select `j7_rank`)) + (select `j8_rank`)) + (select `j9_rank`)) AS `total_rank` from `candidates` `c` where (`c`.`gender` = 0) */;

--
-- Final view structure for view `new_criteria2_rank_m`
--

/*!50001 DROP VIEW IF EXISTS `new_criteria2_rank_m`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `new_criteria2_rank_m` AS select `c`.`id` AS `id`,`c`.`number` AS `number`,`c`.`fullname` AS `fullname`,(select `new_criteria2`.`total` from `new_criteria2` where ((`new_criteria2`.`candidate_id` = `c`.`id`) and (`new_criteria2`.`judge_id` = 1))) AS `j1_score`,(select `NEWCRITERIA2_GETRANK_PERJUDGE`(1,`c`.`id`,`c`.`gender`)) AS `j1_rank`,(select `new_criteria2`.`total` from `new_criteria2` where ((`new_criteria2`.`candidate_id` = `c`.`id`) and (`new_criteria2`.`judge_id` = 2))) AS `j2_score`,(select `NEWCRITERIA2_GETRANK_PERJUDGE`(2,`c`.`id`,`c`.`gender`)) AS `j2_rank`,(select `new_criteria2`.`total` from `new_criteria2` where ((`new_criteria2`.`candidate_id` = `c`.`id`) and (`new_criteria2`.`judge_id` = 3))) AS `j3_score`,(select `NEWCRITERIA2_GETRANK_PERJUDGE`(3,`c`.`id`,`c`.`gender`)) AS `j3_rank`,(select `new_criteria2`.`total` from `new_criteria2` where ((`new_criteria2`.`candidate_id` = `c`.`id`) and (`new_criteria2`.`judge_id` = 4))) AS `j4_score`,(select `NEWCRITERIA2_GETRANK_PERJUDGE`(4,`c`.`id`,`c`.`gender`)) AS `j4_rank`,(select `new_criteria2`.`total` from `new_criteria2` where ((`new_criteria2`.`candidate_id` = `c`.`id`) and (`new_criteria2`.`judge_id` = 5))) AS `j5_score`,(select `NEWCRITERIA2_GETRANK_PERJUDGE`(5,`c`.`id`,`c`.`gender`)) AS `j5_rank`,(select `new_criteria2`.`total` from `new_criteria2` where ((`new_criteria2`.`candidate_id` = `c`.`id`) and (`new_criteria2`.`judge_id` = 6))) AS `j6_score`,(select `NEWCRITERIA2_GETRANK_PERJUDGE`(6,`c`.`id`,`c`.`gender`)) AS `j6_rank`,(select `new_criteria2`.`total` from `new_criteria2` where ((`new_criteria2`.`candidate_id` = `c`.`id`) and (`new_criteria2`.`judge_id` = 7))) AS `j7_score`,(select `NEWCRITERIA2_GETRANK_PERJUDGE`(7,`c`.`id`,`c`.`gender`)) AS `j7_rank`,(select `new_criteria2`.`total` from `new_criteria2` where ((`new_criteria2`.`candidate_id` = `c`.`id`) and (`new_criteria2`.`judge_id` = 8))) AS `j8_score`,(select `NEWCRITERIA2_GETRANK_PERJUDGE`(8,`c`.`id`,`c`.`gender`)) AS `j8_rank`,(select `new_criteria2`.`total` from `new_criteria2` where ((`new_criteria2`.`candidate_id` = `c`.`id`) and (`new_criteria2`.`judge_id` = 9))) AS `j9_score`,(select `NEWCRITERIA2_GETRANK_PERJUDGE`(9,`c`.`id`,`c`.`gender`)) AS `j9_rank`,(((((((((select `j1_rank`) + (select `j2_rank`)) + (select `j3_rank`)) + (select `j4_rank`)) + (select `j5_rank`)) + (select `j6_rank`)) + (select `j7_rank`)) + (select `j8_rank`)) + (select `j9_rank`)) AS `total_rank` from `candidates` `c` where (`c`.`gender` = 1) */;

--
-- Final view structure for view `new_criteria_rank_f`
--

/*!50001 DROP VIEW IF EXISTS `new_criteria_rank_f`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `new_criteria_rank_f` AS select `c`.`id` AS `id`,`c`.`number` AS `number`,`c`.`fullname` AS `fullname`,(select `new_criteria`.`total` from `new_criteria` where ((`new_criteria`.`candidate_id` = `c`.`id`) and (`new_criteria`.`judge_id` = 1))) AS `j1_score`,(select `NEWCRITERIA_GETRANK_PERJUDGE`(1,`c`.`id`,`c`.`gender`)) AS `j1_rank`,(select `new_criteria`.`total` from `new_criteria` where ((`new_criteria`.`candidate_id` = `c`.`id`) and (`new_criteria`.`judge_id` = 2))) AS `j2_score`,(select `NEWCRITERIA_GETRANK_PERJUDGE`(2,`c`.`id`,`c`.`gender`)) AS `j2_rank`,(select `new_criteria`.`total` from `new_criteria` where ((`new_criteria`.`candidate_id` = `c`.`id`) and (`new_criteria`.`judge_id` = 3))) AS `j3_score`,(select `NEWCRITERIA_GETRANK_PERJUDGE`(3,`c`.`id`,`c`.`gender`)) AS `j3_rank`,(select `new_criteria`.`total` from `new_criteria` where ((`new_criteria`.`candidate_id` = `c`.`id`) and (`new_criteria`.`judge_id` = 4))) AS `j4_score`,(select `NEWCRITERIA_GETRANK_PERJUDGE`(4,`c`.`id`,`c`.`gender`)) AS `j4_rank`,(select `new_criteria`.`total` from `new_criteria` where ((`new_criteria`.`candidate_id` = `c`.`id`) and (`new_criteria`.`judge_id` = 5))) AS `j5_score`,(select `NEWCRITERIA_GETRANK_PERJUDGE`(5,`c`.`id`,`c`.`gender`)) AS `j5_rank`,(select `new_criteria`.`total` from `new_criteria` where ((`new_criteria`.`candidate_id` = `c`.`id`) and (`new_criteria`.`judge_id` = 6))) AS `j6_score`,(select `NEWCRITERIA_GETRANK_PERJUDGE`(6,`c`.`id`,`c`.`gender`)) AS `j6_rank`,(select `new_criteria`.`total` from `new_criteria` where ((`new_criteria`.`candidate_id` = `c`.`id`) and (`new_criteria`.`judge_id` = 7))) AS `j7_score`,(select `NEWCRITERIA_GETRANK_PERJUDGE`(7,`c`.`id`,`c`.`gender`)) AS `j7_rank`,(select `new_criteria`.`total` from `new_criteria` where ((`new_criteria`.`candidate_id` = `c`.`id`) and (`new_criteria`.`judge_id` = 8))) AS `j8_score`,(select `NEWCRITERIA_GETRANK_PERJUDGE`(8,`c`.`id`,`c`.`gender`)) AS `j8_rank`,(select `new_criteria`.`total` from `new_criteria` where ((`new_criteria`.`candidate_id` = `c`.`id`) and (`new_criteria`.`judge_id` = 9))) AS `j9_score`,(select `NEWCRITERIA_GETRANK_PERJUDGE`(9,`c`.`id`,`c`.`gender`)) AS `j9_rank`,(((((((((select `j1_rank`) + (select `j2_rank`)) + (select `j3_rank`)) + (select `j4_rank`)) + (select `j5_rank`)) + (select `j6_rank`)) + (select `j7_rank`)) + (select `j8_rank`)) + (select `j9_rank`)) AS `total_rank` from `candidates` `c` where (`c`.`gender` = 0) */;

--
-- Final view structure for view `new_criteria_rank_m`
--

/*!50001 DROP VIEW IF EXISTS `new_criteria_rank_m`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `new_criteria_rank_m` AS select `c`.`id` AS `id`,`c`.`number` AS `number`,`c`.`fullname` AS `fullname`,(select `new_criteria`.`total` from `new_criteria` where ((`new_criteria`.`candidate_id` = `c`.`id`) and (`new_criteria`.`judge_id` = 1))) AS `j1_score`,(select `NEWCRITERIA_GETRANK_PERJUDGE`(1,`c`.`id`,`c`.`gender`)) AS `j1_rank`,(select `new_criteria`.`total` from `new_criteria` where ((`new_criteria`.`candidate_id` = `c`.`id`) and (`new_criteria`.`judge_id` = 2))) AS `j2_score`,(select `NEWCRITERIA_GETRANK_PERJUDGE`(2,`c`.`id`,`c`.`gender`)) AS `j2_rank`,(select `new_criteria`.`total` from `new_criteria` where ((`new_criteria`.`candidate_id` = `c`.`id`) and (`new_criteria`.`judge_id` = 3))) AS `j3_score`,(select `NEWCRITERIA_GETRANK_PERJUDGE`(3,`c`.`id`,`c`.`gender`)) AS `j3_rank`,(select `new_criteria`.`total` from `new_criteria` where ((`new_criteria`.`candidate_id` = `c`.`id`) and (`new_criteria`.`judge_id` = 4))) AS `j4_score`,(select `NEWCRITERIA_GETRANK_PERJUDGE`(4,`c`.`id`,`c`.`gender`)) AS `j4_rank`,(select `new_criteria`.`total` from `new_criteria` where ((`new_criteria`.`candidate_id` = `c`.`id`) and (`new_criteria`.`judge_id` = 5))) AS `j5_score`,(select `NEWCRITERIA_GETRANK_PERJUDGE`(5,`c`.`id`,`c`.`gender`)) AS `j5_rank`,(select `new_criteria`.`total` from `new_criteria` where ((`new_criteria`.`candidate_id` = `c`.`id`) and (`new_criteria`.`judge_id` = 6))) AS `j6_score`,(select `NEWCRITERIA_GETRANK_PERJUDGE`(6,`c`.`id`,`c`.`gender`)) AS `j6_rank`,(select `new_criteria`.`total` from `new_criteria` where ((`new_criteria`.`candidate_id` = `c`.`id`) and (`new_criteria`.`judge_id` = 7))) AS `j7_score`,(select `NEWCRITERIA_GETRANK_PERJUDGE`(7,`c`.`id`,`c`.`gender`)) AS `j7_rank`,(select `new_criteria`.`total` from `new_criteria` where ((`new_criteria`.`candidate_id` = `c`.`id`) and (`new_criteria`.`judge_id` = 8))) AS `j8_score`,(select `NEWCRITERIA_GETRANK_PERJUDGE`(8,`c`.`id`,`c`.`gender`)) AS `j8_rank`,(select `new_criteria`.`total` from `new_criteria` where ((`new_criteria`.`candidate_id` = `c`.`id`) and (`new_criteria`.`judge_id` = 9))) AS `j9_score`,(select `NEWCRITERIA_GETRANK_PERJUDGE`(9,`c`.`id`,`c`.`gender`)) AS `j9_rank`,(((((((((select `j1_rank`) + (select `j2_rank`)) + (select `j3_rank`)) + (select `j4_rank`)) + (select `j5_rank`)) + (select `j6_rank`)) + (select `j7_rank`)) + (select `j8_rank`)) + (select `j9_rank`)) AS `total_rank` from `candidates` `c` where (`c`.`gender` = 1) */;

--
-- Final view structure for view `prod_number_rank_f`
--

/*!50001 DROP VIEW IF EXISTS `prod_number_rank_f`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `prod_number_rank_f` AS select `c`.`id` AS `id`,`c`.`number` AS `number`,`c`.`fullname` AS `fullname`,(select `prod_number`.`total` from `prod_number` where ((`prod_number`.`candidate_id` = `c`.`id`) and (`prod_number`.`judge_id` = 1))) AS `j1_score`,(select `PRODNUM_GETRANK_PERJUDGE`(1,`c`.`id`,`c`.`gender`)) AS `j1_rank`,(select `prod_number`.`total` from `prod_number` where ((`prod_number`.`candidate_id` = `c`.`id`) and (`prod_number`.`judge_id` = 2))) AS `j2_score`,(select `PRODNUM_GETRANK_PERJUDGE`(2,`c`.`id`,`c`.`gender`)) AS `j2_rank`,(select `prod_number`.`total` from `prod_number` where ((`prod_number`.`candidate_id` = `c`.`id`) and (`prod_number`.`judge_id` = 3))) AS `j3_score`,(select `PRODNUM_GETRANK_PERJUDGE`(3,`c`.`id`,`c`.`gender`)) AS `j3_rank`,(select `prod_number`.`total` from `prod_number` where ((`prod_number`.`candidate_id` = `c`.`id`) and (`prod_number`.`judge_id` = 4))) AS `j4_score`,(select `PRODNUM_GETRANK_PERJUDGE`(4,`c`.`id`,`c`.`gender`)) AS `j4_rank`,(select `prod_number`.`total` from `prod_number` where ((`prod_number`.`candidate_id` = `c`.`id`) and (`prod_number`.`judge_id` = 5))) AS `j5_score`,(select `PRODNUM_GETRANK_PERJUDGE`(5,`c`.`id`,`c`.`gender`)) AS `j5_rank`,(select `prod_number`.`total` from `prod_number` where ((`prod_number`.`candidate_id` = `c`.`id`) and (`prod_number`.`judge_id` = 6))) AS `j6_score`,(select `PRODNUM_GETRANK_PERJUDGE`(6,`c`.`id`,`c`.`gender`)) AS `j6_rank`,(select `prod_number`.`total` from `prod_number` where ((`prod_number`.`candidate_id` = `c`.`id`) and (`prod_number`.`judge_id` = 7))) AS `j7_score`,(select `PRODNUM_GETRANK_PERJUDGE`(7,`c`.`id`,`c`.`gender`)) AS `j7_rank`,(select `prod_number`.`total` from `prod_number` where ((`prod_number`.`candidate_id` = `c`.`id`) and (`prod_number`.`judge_id` = 8))) AS `j8_score`,(select `PRODNUM_GETRANK_PERJUDGE`(8,`c`.`id`,`c`.`gender`)) AS `j8_rank`,(select `prod_number`.`total` from `prod_number` where ((`prod_number`.`candidate_id` = `c`.`id`) and (`prod_number`.`judge_id` = 9))) AS `j9_score`,(select `PRODNUM_GETRANK_PERJUDGE`(9,`c`.`id`,`c`.`gender`)) AS `j9_rank`,(((((((((select `j1_rank`) + (select `j2_rank`)) + (select `j3_rank`)) + (select `j4_rank`)) + (select `j5_rank`)) + (select `j6_rank`)) + (select `j7_rank`)) + (select `j8_rank`)) + (select `j9_rank`)) AS `total_rank` from `candidates` `c` where (`c`.`gender` = 0) */;

--
-- Final view structure for view `prod_number_rank_m`
--

/*!50001 DROP VIEW IF EXISTS `prod_number_rank_m`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `prod_number_rank_m` AS select `c`.`id` AS `id`,`c`.`number` AS `number`,`c`.`fullname` AS `fullname`,(select `prod_number`.`total` from `prod_number` where ((`prod_number`.`candidate_id` = `c`.`id`) and (`prod_number`.`judge_id` = 1))) AS `j1_score`,(select `PRODNUM_GETRANK_PERJUDGE`(1,`c`.`id`,`c`.`gender`)) AS `j1_rank`,(select `prod_number`.`total` from `prod_number` where ((`prod_number`.`candidate_id` = `c`.`id`) and (`prod_number`.`judge_id` = 2))) AS `j2_score`,(select `PRODNUM_GETRANK_PERJUDGE`(2,`c`.`id`,`c`.`gender`)) AS `j2_rank`,(select `prod_number`.`total` from `prod_number` where ((`prod_number`.`candidate_id` = `c`.`id`) and (`prod_number`.`judge_id` = 3))) AS `j3_score`,(select `PRODNUM_GETRANK_PERJUDGE`(3,`c`.`id`,`c`.`gender`)) AS `j3_rank`,(select `prod_number`.`total` from `prod_number` where ((`prod_number`.`candidate_id` = `c`.`id`) and (`prod_number`.`judge_id` = 4))) AS `j4_score`,(select `PRODNUM_GETRANK_PERJUDGE`(4,`c`.`id`,`c`.`gender`)) AS `j4_rank`,(select `prod_number`.`total` from `prod_number` where ((`prod_number`.`candidate_id` = `c`.`id`) and (`prod_number`.`judge_id` = 5))) AS `j5_score`,(select `PRODNUM_GETRANK_PERJUDGE`(5,`c`.`id`,`c`.`gender`)) AS `j5_rank`,(select `prod_number`.`total` from `prod_number` where ((`prod_number`.`candidate_id` = `c`.`id`) and (`prod_number`.`judge_id` = 6))) AS `j6_score`,(select `PRODNUM_GETRANK_PERJUDGE`(6,`c`.`id`,`c`.`gender`)) AS `j6_rank`,(select `prod_number`.`total` from `prod_number` where ((`prod_number`.`candidate_id` = `c`.`id`) and (`prod_number`.`judge_id` = 7))) AS `j7_score`,(select `PRODNUM_GETRANK_PERJUDGE`(7,`c`.`id`,`c`.`gender`)) AS `j7_rank`,(select `prod_number`.`total` from `prod_number` where ((`prod_number`.`candidate_id` = `c`.`id`) and (`prod_number`.`judge_id` = 8))) AS `j8_score`,(select `PRODNUM_GETRANK_PERJUDGE`(8,`c`.`id`,`c`.`gender`)) AS `j8_rank`,(select `prod_number`.`total` from `prod_number` where ((`prod_number`.`candidate_id` = `c`.`id`) and (`prod_number`.`judge_id` = 9))) AS `j9_score`,(select `PRODNUM_GETRANK_PERJUDGE`(9,`c`.`id`,`c`.`gender`)) AS `j9_rank`,(((((((((select `j1_rank`) + (select `j2_rank`)) + (select `j3_rank`)) + (select `j4_rank`)) + (select `j5_rank`)) + (select `j6_rank`)) + (select `j7_rank`)) + (select `j8_rank`)) + (select `j9_rank`)) AS `total_rank` from `candidates` `c` where (`c`.`gender` = 1) */;

--
-- Final view structure for view `swim_wear_rank_f`
--

/*!50001 DROP VIEW IF EXISTS `swim_wear_rank_f`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `swim_wear_rank_f` AS select `c`.`id` AS `id`,`c`.`number` AS `number`,`c`.`fullname` AS `fullname`,(select `swim_wear`.`total` from `swim_wear` where ((`swim_wear`.`candidate_id` = `c`.`id`) and (`swim_wear`.`judge_id` = 1))) AS `j1_score`,(select `SWIMWEAR_GETRANK_PERJUDGE`(1,`c`.`id`,`c`.`gender`)) AS `j1_rank`,(select `swim_wear`.`total` from `swim_wear` where ((`swim_wear`.`candidate_id` = `c`.`id`) and (`swim_wear`.`judge_id` = 2))) AS `j2_score`,(select `SWIMWEAR_GETRANK_PERJUDGE`(2,`c`.`id`,`c`.`gender`)) AS `j2_rank`,(select `swim_wear`.`total` from `swim_wear` where ((`swim_wear`.`candidate_id` = `c`.`id`) and (`swim_wear`.`judge_id` = 3))) AS `j3_score`,(select `SWIMWEAR_GETRANK_PERJUDGE`(3,`c`.`id`,`c`.`gender`)) AS `j3_rank`,(select `swim_wear`.`total` from `swim_wear` where ((`swim_wear`.`candidate_id` = `c`.`id`) and (`swim_wear`.`judge_id` = 4))) AS `j4_score`,(select `SWIMWEAR_GETRANK_PERJUDGE`(4,`c`.`id`,`c`.`gender`)) AS `j4_rank`,(select `swim_wear`.`total` from `swim_wear` where ((`swim_wear`.`candidate_id` = `c`.`id`) and (`swim_wear`.`judge_id` = 5))) AS `j5_score`,(select `SWIMWEAR_GETRANK_PERJUDGE`(5,`c`.`id`,`c`.`gender`)) AS `j5_rank`,(select `swim_wear`.`total` from `swim_wear` where ((`swim_wear`.`candidate_id` = `c`.`id`) and (`swim_wear`.`judge_id` = 6))) AS `j6_score`,(select `SWIMWEAR_GETRANK_PERJUDGE`(6,`c`.`id`,`c`.`gender`)) AS `j6_rank`,(select `swim_wear`.`total` from `swim_wear` where ((`swim_wear`.`candidate_id` = `c`.`id`) and (`swim_wear`.`judge_id` = 7))) AS `j7_score`,(select `SWIMWEAR_GETRANK_PERJUDGE`(7,`c`.`id`,`c`.`gender`)) AS `j7_rank`,(select `swim_wear`.`total` from `swim_wear` where ((`swim_wear`.`candidate_id` = `c`.`id`) and (`swim_wear`.`judge_id` = 8))) AS `j8_score`,(select `SWIMWEAR_GETRANK_PERJUDGE`(8,`c`.`id`,`c`.`gender`)) AS `j8_rank`,(select `swim_wear`.`total` from `swim_wear` where ((`swim_wear`.`candidate_id` = `c`.`id`) and (`swim_wear`.`judge_id` = 9))) AS `j9_score`,(select `SWIMWEAR_GETRANK_PERJUDGE`(9,`c`.`id`,`c`.`gender`)) AS `j9_rank`,(((((((((select `j1_rank`) + (select `j2_rank`)) + (select `j3_rank`)) + (select `j4_rank`)) + (select `j5_rank`)) + (select `j6_rank`)) + (select `j7_rank`)) + (select `j8_rank`)) + (select `j9_rank`)) AS `total_rank` from `candidates` `c` where (`c`.`gender` = 0) */;

--
-- Final view structure for view `swim_wear_rank_m`
--

/*!50001 DROP VIEW IF EXISTS `swim_wear_rank_m`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `swim_wear_rank_m` AS select `c`.`id` AS `id`,`c`.`number` AS `number`,`c`.`fullname` AS `fullname`,(select `swim_wear`.`total` from `swim_wear` where ((`swim_wear`.`candidate_id` = `c`.`id`) and (`swim_wear`.`judge_id` = 1))) AS `j1_score`,(select `SWIMWEAR_GETRANK_PERJUDGE`(1,`c`.`id`,`c`.`gender`)) AS `j1_rank`,(select `swim_wear`.`total` from `swim_wear` where ((`swim_wear`.`candidate_id` = `c`.`id`) and (`swim_wear`.`judge_id` = 2))) AS `j2_score`,(select `SWIMWEAR_GETRANK_PERJUDGE`(2,`c`.`id`,`c`.`gender`)) AS `j2_rank`,(select `swim_wear`.`total` from `swim_wear` where ((`swim_wear`.`candidate_id` = `c`.`id`) and (`swim_wear`.`judge_id` = 3))) AS `j3_score`,(select `SWIMWEAR_GETRANK_PERJUDGE`(3,`c`.`id`,`c`.`gender`)) AS `j3_rank`,(select `swim_wear`.`total` from `swim_wear` where ((`swim_wear`.`candidate_id` = `c`.`id`) and (`swim_wear`.`judge_id` = 4))) AS `j4_score`,(select `SWIMWEAR_GETRANK_PERJUDGE`(4,`c`.`id`,`c`.`gender`)) AS `j4_rank`,(select `swim_wear`.`total` from `swim_wear` where ((`swim_wear`.`candidate_id` = `c`.`id`) and (`swim_wear`.`judge_id` = 5))) AS `j5_score`,(select `SWIMWEAR_GETRANK_PERJUDGE`(5,`c`.`id`,`c`.`gender`)) AS `j5_rank`,(select `swim_wear`.`total` from `swim_wear` where ((`swim_wear`.`candidate_id` = `c`.`id`) and (`swim_wear`.`judge_id` = 6))) AS `j6_score`,(select `SWIMWEAR_GETRANK_PERJUDGE`(6,`c`.`id`,`c`.`gender`)) AS `j6_rank`,(select `swim_wear`.`total` from `swim_wear` where ((`swim_wear`.`candidate_id` = `c`.`id`) and (`swim_wear`.`judge_id` = 7))) AS `j7_score`,(select `SWIMWEAR_GETRANK_PERJUDGE`(7,`c`.`id`,`c`.`gender`)) AS `j7_rank`,(select `swim_wear`.`total` from `swim_wear` where ((`swim_wear`.`candidate_id` = `c`.`id`) and (`swim_wear`.`judge_id` = 8))) AS `j8_score`,(select `SWIMWEAR_GETRANK_PERJUDGE`(8,`c`.`id`,`c`.`gender`)) AS `j8_rank`,(select `swim_wear`.`total` from `swim_wear` where ((`swim_wear`.`candidate_id` = `c`.`id`) and (`swim_wear`.`judge_id` = 9))) AS `j9_score`,(select `SWIMWEAR_GETRANK_PERJUDGE`(9,`c`.`id`,`c`.`gender`)) AS `j9_rank`,(((((((((select `j1_rank`) + (select `j2_rank`)) + (select `j3_rank`)) + (select `j4_rank`)) + (select `j5_rank`)) + (select `j6_rank`)) + (select `j7_rank`)) + (select `j8_rank`)) + (select `j9_rank`)) AS `total_rank` from `candidates` `c` where (`c`.`gender` = 1) */;

--
-- Final view structure for view `tabulation_f`
--

/*!50001 DROP VIEW IF EXISTS `tabulation_f`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `tabulation_f` AS select `c`.`id` AS `id`,`c`.`number` AS `number`,`c`.`fullname` AS `fullname`,(select `prod_number_rank_f`.`total_rank` from `prod_number_rank_f` where (`prod_number_rank_f`.`id` = `c`.`id`)) AS `prodnum`,(select (`prodnum` * 0.15)) AS `computed_prodnum`,(select `swim_wear_rank_f`.`total_rank` from `swim_wear_rank_f` where (`swim_wear_rank_f`.`id` = `c`.`id`)) AS `swimwear`,(select (`swimwear` * 0.15)) AS `computed_swimwear`,(select `talent_rank_f`.`total_rank` from `talent_rank_f` where (`talent_rank_f`.`id` = `c`.`id`)) AS `talent`,(select (`talent` * 0.20)) AS `computed_talent`,(select `formal_wear_rank_f`.`total_rank` from `formal_wear_rank_f` where (`formal_wear_rank_f`.`id` = `c`.`id`)) AS `formalwear`,(select (`formalwear` * 0.20)) AS `computed_formalwear`,(select `interview_rank_f`.`total_rank` from `interview_rank_f` where (`interview_rank_f`.`id` = `c`.`id`)) AS `interview`,(select (`interview` * 0.30)) AS `computed_interview`,(select ((((`computed_prodnum` + `computed_swimwear`) + `computed_talent`) + `computed_formalwear`) + `computed_interview`)) AS `computed_final` from `candidates` `c` where (`c`.`gender` = 0) order by (select ((((`computed_prodnum` + `computed_swimwear`) + `computed_talent`) + `computed_formalwear`) + `computed_interview`)) */;

--
-- Final view structure for view `tabulation_f2`
--

/*!50001 DROP VIEW IF EXISTS `tabulation_f2`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `tabulation_f2` AS select `c`.`id` AS `id`,`c`.`number` AS `number`,`c`.`fullname` AS `fullname`,(select `prod_number_rank_f`.`total_rank` from `prod_number_rank_f` where (`prod_number_rank_f`.`id` = `c`.`id`)) AS `prodnum`,(select `swim_wear_rank_f`.`total_rank` from `swim_wear_rank_f` where (`swim_wear_rank_f`.`id` = `c`.`id`)) AS `swimwear`,(select `talent_rank_f`.`total_rank` from `talent_rank_f` where (`talent_rank_f`.`id` = `c`.`id`)) AS `talent`,(select `formal_wear_rank_f`.`total_rank` from `formal_wear_rank_f` where (`formal_wear_rank_f`.`id` = `c`.`id`)) AS `formalwear`,(select `interview_rank_f`.`total_rank` from `interview_rank_f` where (`interview_rank_f`.`id` = `c`.`id`)) AS `interview`,(select ((((`prodnum` + `swimwear`) + `talent`) + `formalwear`) + `interview`)) AS `computed_final` from `candidates` `c` where (`c`.`gender` = 0) order by (select ((((`prodnum` + `swimwear`) + `talent`) + `formalwear`) + `interview`)) */;

--
-- Final view structure for view `tabulation_m`
--

/*!50001 DROP VIEW IF EXISTS `tabulation_m`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `tabulation_m` AS select `c`.`id` AS `id`,`c`.`number` AS `number`,`c`.`fullname` AS `fullname`,(select `prod_number_rank_m`.`total_rank` from `prod_number_rank_m` where (`prod_number_rank_m`.`id` = `c`.`id`)) AS `prodnum`,(select (`prodnum` * 0.15)) AS `computed_prodnum`,(select `swim_wear_rank_m`.`total_rank` from `swim_wear_rank_m` where (`swim_wear_rank_m`.`id` = `c`.`id`)) AS `swimwear`,(select (`swimwear` * 0.15)) AS `computed_swimwear`,(select `talent_rank_m`.`total_rank` from `talent_rank_m` where (`talent_rank_m`.`id` = `c`.`id`)) AS `talent`,(select (`talent` * 0.20)) AS `computed_talent`,(select `formal_wear_rank_m`.`total_rank` from `formal_wear_rank_m` where (`formal_wear_rank_m`.`id` = `c`.`id`)) AS `formalwear`,(select (`formalwear` * 0.20)) AS `computed_formalwear`,(select `interview_rank_m`.`total_rank` from `interview_rank_m` where (`interview_rank_m`.`id` = `c`.`id`)) AS `interview`,(select (`interview` * 0.30)) AS `computed_interview`,(select ((((`computed_prodnum` + `computed_swimwear`) + `computed_talent`) + `computed_formalwear`) + `computed_interview`)) AS `computed_final` from `candidates` `c` where (`c`.`gender` = 1) order by (select ((((`computed_prodnum` + `computed_swimwear`) + `computed_talent`) + `computed_formalwear`) + `computed_interview`)) */;

--
-- Final view structure for view `tabulation_m2`
--

/*!50001 DROP VIEW IF EXISTS `tabulation_m2`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `tabulation_m2` AS select `c`.`id` AS `id`,`c`.`number` AS `number`,`c`.`fullname` AS `fullname`,(select `prod_number_rank_m`.`total_rank` from `prod_number_rank_m` where (`prod_number_rank_m`.`id` = `c`.`id`)) AS `prodnum`,(select `swim_wear_rank_m`.`total_rank` from `swim_wear_rank_m` where (`swim_wear_rank_m`.`id` = `c`.`id`)) AS `swimwear`,(select `talent_rank_m`.`total_rank` from `talent_rank_m` where (`talent_rank_m`.`id` = `c`.`id`)) AS `talent`,(select `formal_wear_rank_m`.`total_rank` from `formal_wear_rank_m` where (`formal_wear_rank_m`.`id` = `c`.`id`)) AS `formalwear`,(select `interview_rank_m`.`total_rank` from `interview_rank_m` where (`interview_rank_m`.`id` = `c`.`id`)) AS `interview`,(select ((((`prodnum` + `swimwear`) + `talent`) + `formalwear`) + `interview`)) AS `computed_final` from `candidates` `c` where (`c`.`gender` = 1) order by (select ((((`prodnum` + `swimwear`) + `talent`) + `formalwear`) + `interview`)) */;

--
-- Final view structure for view `talent_rank_f`
--

/*!50001 DROP VIEW IF EXISTS `talent_rank_f`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `talent_rank_f` AS select `c`.`id` AS `id`,`c`.`number` AS `number`,`c`.`fullname` AS `fullname`,(select `talent`.`total` from `talent` where ((`talent`.`candidate_id` = `c`.`id`) and (`talent`.`judge_id` = 1))) AS `j1_score`,(select `TALENT_GETRANK_PERJUDGE`(1,`c`.`id`,`c`.`gender`)) AS `j1_rank`,(select `talent`.`total` from `talent` where ((`talent`.`candidate_id` = `c`.`id`) and (`talent`.`judge_id` = 2))) AS `j2_score`,(select `TALENT_GETRANK_PERJUDGE`(2,`c`.`id`,`c`.`gender`)) AS `j2_rank`,(select `talent`.`total` from `talent` where ((`talent`.`candidate_id` = `c`.`id`) and (`talent`.`judge_id` = 3))) AS `j3_score`,(select `TALENT_GETRANK_PERJUDGE`(3,`c`.`id`,`c`.`gender`)) AS `j3_rank`,(select `talent`.`total` from `talent` where ((`talent`.`candidate_id` = `c`.`id`) and (`talent`.`judge_id` = 4))) AS `j4_score`,(select `TALENT_GETRANK_PERJUDGE`(4,`c`.`id`,`c`.`gender`)) AS `j4_rank`,(select `talent`.`total` from `talent` where ((`talent`.`candidate_id` = `c`.`id`) and (`talent`.`judge_id` = 5))) AS `j5_score`,(select `TALENT_GETRANK_PERJUDGE`(5,`c`.`id`,`c`.`gender`)) AS `j5_rank`,(select `talent`.`total` from `talent` where ((`talent`.`candidate_id` = `c`.`id`) and (`talent`.`judge_id` = 6))) AS `j6_score`,(select `TALENT_GETRANK_PERJUDGE`(6,`c`.`id`,`c`.`gender`)) AS `j6_rank`,(select `talent`.`total` from `talent` where ((`talent`.`candidate_id` = `c`.`id`) and (`talent`.`judge_id` = 7))) AS `j7_score`,(select `TALENT_GETRANK_PERJUDGE`(7,`c`.`id`,`c`.`gender`)) AS `j7_rank`,(select `talent`.`total` from `talent` where ((`talent`.`candidate_id` = `c`.`id`) and (`talent`.`judge_id` = 8))) AS `j8_score`,(select `TALENT_GETRANK_PERJUDGE`(8,`c`.`id`,`c`.`gender`)) AS `j8_rank`,(select `talent`.`total` from `talent` where ((`talent`.`candidate_id` = `c`.`id`) and (`talent`.`judge_id` = 9))) AS `j9_score`,(select `TALENT_GETRANK_PERJUDGE`(9,`c`.`id`,`c`.`gender`)) AS `j9_rank`,(((((((((select `j1_rank`) + (select `j2_rank`)) + (select `j3_rank`)) + (select `j4_rank`)) + (select `j5_rank`)) + (select `j6_rank`)) + (select `j7_rank`)) + (select `j8_rank`)) + (select `j9_rank`)) AS `total_rank` from `candidates` `c` where (`c`.`gender` = 0) */;

--
-- Final view structure for view `talent_rank_m`
--

/*!50001 DROP VIEW IF EXISTS `talent_rank_m`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `talent_rank_m` AS select `c`.`id` AS `id`,`c`.`number` AS `number`,`c`.`fullname` AS `fullname`,(select `talent`.`total` from `talent` where ((`talent`.`candidate_id` = `c`.`id`) and (`talent`.`judge_id` = 1))) AS `j1_score`,(select `TALENT_GETRANK_PERJUDGE`(1,`c`.`id`,`c`.`gender`)) AS `j1_rank`,(select `talent`.`total` from `talent` where ((`talent`.`candidate_id` = `c`.`id`) and (`talent`.`judge_id` = 2))) AS `j2_score`,(select `TALENT_GETRANK_PERJUDGE`(2,`c`.`id`,`c`.`gender`)) AS `j2_rank`,(select `talent`.`total` from `talent` where ((`talent`.`candidate_id` = `c`.`id`) and (`talent`.`judge_id` = 3))) AS `j3_score`,(select `TALENT_GETRANK_PERJUDGE`(3,`c`.`id`,`c`.`gender`)) AS `j3_rank`,(select `talent`.`total` from `talent` where ((`talent`.`candidate_id` = `c`.`id`) and (`talent`.`judge_id` = 4))) AS `j4_score`,(select `TALENT_GETRANK_PERJUDGE`(4,`c`.`id`,`c`.`gender`)) AS `j4_rank`,(select `talent`.`total` from `talent` where ((`talent`.`candidate_id` = `c`.`id`) and (`talent`.`judge_id` = 5))) AS `j5_score`,(select `TALENT_GETRANK_PERJUDGE`(5,`c`.`id`,`c`.`gender`)) AS `j5_rank`,(select `talent`.`total` from `talent` where ((`talent`.`candidate_id` = `c`.`id`) and (`talent`.`judge_id` = 6))) AS `j6_score`,(select `TALENT_GETRANK_PERJUDGE`(6,`c`.`id`,`c`.`gender`)) AS `j6_rank`,(select `talent`.`total` from `talent` where ((`talent`.`candidate_id` = `c`.`id`) and (`talent`.`judge_id` = 7))) AS `j7_score`,(select `TALENT_GETRANK_PERJUDGE`(7,`c`.`id`,`c`.`gender`)) AS `j7_rank`,(select `talent`.`total` from `talent` where ((`talent`.`candidate_id` = `c`.`id`) and (`talent`.`judge_id` = 8))) AS `j8_score`,(select `TALENT_GETRANK_PERJUDGE`(8,`c`.`id`,`c`.`gender`)) AS `j8_rank`,(select `talent`.`total` from `talent` where ((`talent`.`candidate_id` = `c`.`id`) and (`talent`.`judge_id` = 9))) AS `j9_score`,(select `TALENT_GETRANK_PERJUDGE`(9,`c`.`id`,`c`.`gender`)) AS `j9_rank`,(((((((((select `j1_rank`) + (select `j2_rank`)) + (select `j3_rank`)) + (select `j4_rank`)) + (select `j5_rank`)) + (select `j6_rank`)) + (select `j7_rank`)) + (select `j8_rank`)) + (select `j9_rank`)) AS `total_rank` from `candidates` `c` where (`c`.`gender` = 1) */;


