#Issue284 finally done

parent 55306082
-- MySQL dump 10.13 Distrib 5.7.19, for Linux (x86_64)
--
-- Host: localhost Database: pictodb
-- ------------------------------------------------------
-- Server version 5.7.19-0ubuntu0.16.04.1
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `action`
--
DROP TABLE IF EXISTS `action`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `action` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`type` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
`timestamp` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
`id_sup` int(11) DEFAULT NULL,
`id_stu` int(11) NOT NULL,
`id_try` int(11) DEFAULT NULL,
`description` varchar(4096) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'serialization of properties of the picto at the time of the action',
`gps_lat` float DEFAULT NULL,
`gps_lon` float DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `uq_stuact` (`id_stu`,`timestamp`),
UNIQUE KEY `id_stu` (`id_stu`,`timestamp`),
UNIQUE KEY `uq_supact` (`id_sup`,`timestamp`),
KEY `fk_sup_act` (`id_sup`),
KEY `fk_stu_act` (`id_stu`),
KEY `id_try` (`id_try`),
CONSTRAINT `fk_stu_act` FOREIGN KEY (`id_stu`) REFERENCES `student` (`id`),
CONSTRAINT `fk_sup_act` FOREIGN KEY (`id_sup`) REFERENCES `supervisor` (`id`),
CONSTRAINT `fk_try_act` FOREIGN KEY (`id_try`) REFERENCES `try` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='This table registers and action performed by a user at a given time, all information of the action is in JSON format in the ''description'' column and the operation performed is one of the possible for the ''type'' column. NOTE: timestamps must support fractional seconds, so MySQL versions >= 5.6.4 are required.';
/*!40101 SET character_set_client = @saved_cs_client */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = latin1 */ ;
/*!50003 SET character_set_results = latin1 */ ;
/*!50003 SET collation_connection = latin1_swedish_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER TRG_NEW_EVENT_ONSESSION
BEFORE INSERT ON action
FOR EACH ROW
thisTrigger: BEGIN
DECLARE idstu INT;
DECLARE idtry INT;
IF ((@TRIGGER_CHECKS = FALSE)
OR (@TRIGGER_BEFORE_INSERT_CHECKS = FALSE))
AND (USER() = 'root@localhost')
THEN
LEAVE thisTrigger;
END IF;
SELECT id_opentry INTO idtry
FROM
stu_opentry
WHERE
id_stu = NEW.id_stu;
IF (idtry IS NOT NULL) THEN
SET NEW.id_try = idtry;
END IF;
IF (NEW.type = 'resumesession')
THEN
SET NEW.id_try=NULL;
END IF;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = latin1 */ ;
/*!50003 SET character_set_results = latin1 */ ;
/*!50003 SET collation_connection = latin1_swedish_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER TRG_NEW_EVENT
AFTER INSERT ON action
FOR EACH ROW
thisTrigger: BEGIN
DECLARE idopentry INT;
DECLARE idws INT;
IF ((@TRIGGER_CHECKS = FALSE)
OR (@TRIGGER_AFTER_INSERT_CHECKS = FALSE))
AND (USER() = 'root@localhost')
THEN
LEAVE thisTrigger;
END IF;
SELECT id_ws, id_opentry INTO idws, idopentry
FROM
stu_opentry
WHERE
id_stu = NEW.id_stu;
IF (NEW.id_try IS NOT NULL) THEN
UPDATE `try`
SET
end = NEW.timestamp
WHERE
id = idopentry;
END IF;
CASE NEW.type
WHEN 'Show' THEN
IF (idopentry IS NOT NULL) THEN
INSERT INTO try(`id_ws`)
VALUES (idws);
END IF;
WHEN 'pausesession' THEN
IF (idopentry IS NOT NULL) THEN
UPDATE try
SET
result = 'DISCARDED'
WHERE
id = idopentry;
UPDATE stu_opentry
SET id_opentry=NULL
WHERE id_ws = idws;
END IF;
WHEN 'resumesession' THEN
INSERT INTO try(`id_ws`)
VALUES (idws);
ELSE BEGIN END;
END CASE;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
--
-- Table structure for table `catexp`
--
DROP TABLE IF EXISTS `catexp`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `catexp` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_cat` int(11) NOT NULL,
`lang` char(5) DEFAULT NULL,
`exp` varchar(30) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `exp` (`exp`,`lang`)
) ENGINE=InnoDB AUTO_INCREMENT=27958 DEFAULT CHARSET=utf8 COMMENT='Stores the expressions available in several languages for a given category (id_cat)';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `instruction`
--
DROP TABLE IF EXISTS `instruction`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `instruction` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_met` int(11) NOT NULL,
`name` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`objective` varchar(512) COLLATE utf8_unicode_ci DEFAULT NULL,
`status` varchar(60) COLLATE utf8_unicode_ci DEFAULT NULL,
`begin` timestamp(3) NULL DEFAULT NULL,
`end` timestamp(3) NULL DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `fk_met_ins` (`id_met`),
CONSTRAINT `fk_met_ins` FOREIGN KEY (`id_met`) REFERENCES `method` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='An instruction is a ''phase'' in a method for learning AAC';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `license`
--
DROP TABLE IF EXISTS `license`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `license` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_stu` int(11) DEFAULT NULL,
`number` varchar(16) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`creation_ts` datetime DEFAULT CURRENT_TIMESTAMP,
`activation_ts` datetime DEFAULT NULL,
`expiration_ts` datetime DEFAULT NULL,
`duration` int(11) DEFAULT '0',
`creator` varchar(40) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `number` (`number`),
KEY `id_stu` (`id_stu`),
CONSTRAINT `license_fk_1` FOREIGN KEY (`id_stu`) REFERENCES `student` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Student license number';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `meta_instruction`
--
DROP TABLE IF EXISTS `meta_instruction`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `meta_instruction` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`objective` varchar(512) COLLATE utf8_unicode_ci DEFAULT NULL,
`id_met` tinyint(4) NOT NULL,
`lang` char(5) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`),
KEY `fk_ins_met` (`id_met`),
CONSTRAINT `fk_ins_met` FOREIGN KEY (`id_met`) REFERENCES `meta_method` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='One in a set of instructions predefined or stored by users. They are related to a metamethod (id_met)';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `meta_method`
--
DROP TABLE IF EXISTS `meta_method`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `meta_method` (
`id` tinyint(4) NOT NULL AUTO_INCREMENT,
`name` varchar(60) COLLATE utf8_unicode_ci NOT NULL,
`description` varchar(4096) COLLATE utf8_unicode_ci DEFAULT NULL,
`id_sup` int(11) DEFAULT NULL,
`lang` char(5) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`,`id_sup`),
KEY `fk_met_sup` (`id_sup`),
CONSTRAINT `fk_met_sup` FOREIGN KEY (`id_sup`) REFERENCES `supervisor` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Methods predefined in the platform or stored by users for cloning';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `method`
--
DROP TABLE IF EXISTS `method`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `method` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
`description` varchar(4096) COLLATE utf8_unicode_ci DEFAULT NULL,
`id_stu` int(11) NOT NULL,
`registration` date DEFAULT NULL,
`notes` varchar(4096) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `fk_stu_met` (`id_stu`),
CONSTRAINT `fk_stu_met` FOREIGN KEY (`id_stu`) REFERENCES `student` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Information for a method. A method is composed by a set of instructions';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `picto`
--
DROP TABLE IF EXISTS `picto`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `picto` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`uri` varchar(250) COLLATE utf8_unicode_ci NOT NULL,
`id_src` tinyint(4) NOT NULL,
`id_owner` int(11) DEFAULT NULL,
`id_cat` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `ck_pic` (`id_owner`,`id_src`,`uri`),
KEY `fk_sou_pic` (`id_src`)
) ENGINE=InnoDB AUTO_INCREMENT=122306 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Main information about a pictogram, either coming from a source like Symbolstix or added by a supervisor. It can belongs to a category (id_cat)';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `picto_acl`
--
DROP TABLE IF EXISTS `picto_acl`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `picto_acl` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_sup` int(11) NOT NULL DEFAULT '0',
`id_pic` int(11) NOT NULL DEFAULT '0',
`privilege` varchar(1) COLLATE utf8_unicode_ci NOT NULL,
`timestamp` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
PRIMARY KEY (`id`),
KEY `k_pic_aclp` (`id_pic`),
KEY `k_sup_aclp` (`id_sup`),
CONSTRAINT `fk_pic_aclp` FOREIGN KEY (`id_pic`) REFERENCES `picto` (`id`),
CONSTRAINT `fk_sup_aclp` FOREIGN KEY (`id_sup`) REFERENCES `supervisor` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Stablish access rights to pictos';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `picto_core`
--
DROP TABLE IF EXISTS `picto_core`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `picto_core` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_pic` int(11) DEFAULT NULL COMMENT 'This is the id of the pictogram',
`id_cat_pic` int(11) DEFAULT NULL COMMENT 'This is the id of the pictogram that represents the category this entry belongs to',
`coord_x` tinyint(4) NOT NULL,
`coord_y` tinyint(4) NOT NULL,
`color` varchar(9) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `id_pic` (`id_pic`),
KEY `id_cat_pic` (`id_cat_pic`),
CONSTRAINT `picto_core_ibfk_1` FOREIGN KEY (`id_cat_pic`) REFERENCES `picto` (`id`),
CONSTRAINT `picto_core_ibfk_2` FOREIGN KEY (`id_pic`) REFERENCES `picto` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=233 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Default pictos and categories available for a newly created student with default coordinates';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `picto_exp`
--
DROP TABLE IF EXISTS `picto_exp`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `picto_exp` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_pic` int(11) NOT NULL,
`lang` char(5) COLLATE utf8_unicode_ci NOT NULL,
`text` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`),
KEY `id_pic` (`id_pic`)
) ENGINE=InnoDB AUTO_INCREMENT=197728 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Expression (text label) for a picto (or a category) in different languages. This is used by the TTS engine';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `picto_tag`
--
DROP TABLE IF EXISTS `picto_tag`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `picto_tag` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_sup` int(11) DEFAULT NULL COMMENT 'If NULL then is a default tag',
`id_pic` int(11) NOT NULL,
`tag` varchar(80) COLLATE utf8_unicode_ci NOT NULL,
`lang` char(5) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`),
KEY `id_pic` (`id_pic`),
KEY `id_sup` (`id_sup`),
CONSTRAINT `fk_con_pt` FOREIGN KEY (`id_pic`) REFERENCES `picto` (`id`),
CONSTRAINT `picto_tag_ibfk_1` FOREIGN KEY (`id_sup`) REFERENCES `supervisor` (`id`),
CONSTRAINT `picto_tag_ibfk_2` FOREIGN KEY (`id_pic`) REFERENCES `picto` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=37052 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Labels assigned to pictos by default or by supervisors';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `pictocat`
--
DROP TABLE IF EXISTS `pictocat`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `pictocat` (
`id` int(11) NOT NULL,
`id_supercat` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Identifies a category, which, itself, may belong to another category';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `pictocattree`
--
DROP TABLE IF EXISTS `pictocattree`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `pictocattree` (
`id_cat` int(11) NOT NULL,
`id_ancestor` int(11) NOT NULL,
PRIMARY KEY (`id_cat`,`id_ancestor`),
KEY `id_ancestor` (`id_ancestor`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `scene`
--
DROP TABLE IF EXISTS `scene`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `scene` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`categories` tinyint(1) NOT NULL DEFAULT '0',
`id_sup` int(11) DEFAULT NULL,
`id_stu` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `id_sup` (`id_sup`),
KEY `id_stu` (`id_stu`),
CONSTRAINT `scene_ibfk_1` FOREIGN KEY (`id_sup`) REFERENCES `supervisor` (`id`),
CONSTRAINT `scene_ibfk_2` FOREIGN KEY (`id_stu`) REFERENCES `student` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Scene table information. Every scene is related to some stu_pictos';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `source`
--
DROP TABLE IF EXISTS `source`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `source` (
`id` tinyint(4) NOT NULL AUTO_INCREMENT,
`name` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
`description` varchar(4096) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Contains all possible sources of pictos';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `stu_off`
--
DROP TABLE IF EXISTS `stu_off`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `stu_off` (
`id_stu` int(11) NOT NULL,
`id_off` int(11) DEFAULT NULL,
KEY `fk_stu_off` (`id_stu`),
KEY `fk_off_stu` (`id_off`),
CONSTRAINT `fk_off_stu` FOREIGN KEY (`id_off`) REFERENCES `supervisor` (`id`),
CONSTRAINT `fk_stu_off` FOREIGN KEY (`id_stu`) REFERENCES `student` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `stu_opentry`
--
DROP TABLE IF EXISTS `stu_opentry`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `stu_opentry` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_stu` int(11) NOT NULL,
`id_sup` int(11) NOT NULL,
`id_ws` int(11) NOT NULL,
`id_opentry` int(11) DEFAULT NULL,
`total_tries` int(11) DEFAULT '0',
`begin` timestamp(3) NULL DEFAULT NULL,
`end` timestamp(3) NULL DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `id_stu` (`id_stu`),
UNIQUE KEY `id_sup` (`id_sup`),
UNIQUE KEY `id_ws` (`id_ws`),
KEY `id_opentry` (`id_opentry`),
CONSTRAINT `stu_opentry_ibfk_1` FOREIGN KEY (`id_stu`) REFERENCES `student` (`id`),
CONSTRAINT `stu_opentry_ibfk_2` FOREIGN KEY (`id_opentry`) REFERENCES `try` (`id`) ON DELETE SET NULL,
CONSTRAINT `stu_opentry_ibfk_3` FOREIGN KEY (`id_ws`) REFERENCES `working_session` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `stu_picto`
--
DROP TABLE IF EXISTS `stu_picto`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `stu_picto` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_stu` int(11) NOT NULL,
`id_pic` int(11) NOT NULL,
`attributes` varchar(1000) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'JSON object describing the properties of the picto',
`id_scene` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `fk_picto` (`id_pic`),
KEY `id_stu` (`id_stu`),
KEY `stu_picto_scene_fk` (`id_scene`),
CONSTRAINT `fk_picto` FOREIGN KEY (`id_pic`) REFERENCES `picto` (`id`),
CONSTRAINT `stu_picto_ibfk_1` FOREIGN KEY (`id_stu`) REFERENCES `student` (`id`),
CONSTRAINT `stu_picto_scene_fk` FOREIGN KEY (`id_scene`) REFERENCES `scene` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='This table relates a student with the pictos in her vocabulary';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `stu_sup`
--
DROP TABLE IF EXISTS `stu_sup`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `stu_sup` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_stu` int(11) NOT NULL,
`id_sup` int(11) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `fk_stu_sup_ss` (`id_stu`,`id_sup`),
KEY `fk_sup_ss` (`id_sup`),
KEY `id_stu` (`id_stu`),
CONSTRAINT `stu_sup_ibfk_1` FOREIGN KEY (`id_stu`) REFERENCES `student` (`id`) ON DELETE CASCADE,
CONSTRAINT `stu_sup_ibfk_2` FOREIGN KEY (`id_sup`) REFERENCES `supervisor` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=48 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='This table relates students and supervisors';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `student`
--
DROP TABLE IF EXISTS `student`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `student` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
`password` varchar(60) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`name` varchar(40) COLLATE utf8_unicode_ci DEFAULT NULL,
`surname` varchar(60) COLLATE utf8_unicode_ci DEFAULT NULL,
`birthdate` date DEFAULT NULL,
`gender` char(1) COLLATE utf8_unicode_ci DEFAULT NULL,
`country` char(2) COLLATE utf8_unicode_ci DEFAULT NULL,
`pic` varchar(255) COLLATE utf8_unicode_ci DEFAULT 'defaultAvatar.jpg',
`notes` varchar(4096) COLLATE utf8_unicode_ci DEFAULT NULL,
`lang` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
`attributes` varchar(4096) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Attributes describing student along with his/her configuration',
`id_active_scene` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `username` (`username`)
) ENGINE=InnoDB AUTO_INCREMENT=29 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Students information';
/*!40101 SET character_set_client = @saved_cs_client */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = latin1 */ ;
/*!50003 SET character_set_results = latin1 */ ;
/*!50003 SET collation_connection = latin1_swedish_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER TRG_NEW_STUDENT_UPDATE_ENROLMENTS
AFTER INSERT ON student
FOR EACH ROW
thisTrigger: BEGIN
DECLARE LID INT;
IF ((@TRIGGER_CHECKS = FALSE)
OR (@TRIGGER_AFTER_INSERT_CHECKS = FALSE))
AND (USER() = 'root@localhost')
THEN
LEAVE thisTrigger;
END IF;
INSERT INTO scene (id_stu,id_sup,name,categories) VALUES (NEW.id, null, 'with_categories', TRUE);
SET LID = LAST_INSERT_ID();
CALL scene_create_core(LID,new.id);
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = latin1 */ ;
/*!50003 SET character_set_results = latin1 */ ;
/*!50003 SET collation_connection = latin1_swedish_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER TRG_MODIFY_STUDENT_ENROLMENTS
AFTER UPDATE ON student
FOR EACH ROW
thisTrigger: BEGIN
IF ((@TRIGGER_CHECKS = FALSE)
OR (@TRIGGER_AFTER_UPDATE_CHECKS = FALSE))
AND (USER() = 'root@localhost')
THEN
LEAVE thisTrigger;
END IF;
IF NOT (old.id_off<=>new.id_off) THEN
IF (old.id_off IS NOT NULL) THEN
DELETE
stu_sup
FROM
stu_sup INNER JOIN supervisor ON (stu_sup.id_sup=supervisor.id)
WHERE
id_stu=new.id AND old.id_off=supervisor.id_off;
END IF;
END IF;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
--
-- Table structure for table `sup_off`
--
DROP TABLE IF EXISTS `sup_off`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `sup_off` (
`id_sup` int(11) NOT NULL,
`id_off` int(11) DEFAULT NULL,
KEY `fk_sup_off` (`id_sup`),
KEY `fk_off_sup` (`id_off`),
CONSTRAINT `fk_off_sup` FOREIGN KEY (`id_off`) REFERENCES `supervisor` (`id`),
CONSTRAINT `fk_sup_off` FOREIGN KEY (`id_sup`) REFERENCES `supervisor` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `supervisor`
--
DROP TABLE IF EXISTS `supervisor`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `supervisor` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(40) COLLATE utf8_unicode_ci DEFAULT NULL,
`surname` varchar(60) COLLATE utf8_unicode_ci DEFAULT NULL,
`gender` char(1) COLLATE utf8_unicode_ci DEFAULT NULL,
`pic` varchar(255) COLLATE utf8_unicode_ci DEFAULT 'defaultAvatar.jpg',
`address` varchar(180) COLLATE utf8_unicode_ci DEFAULT NULL,
`postal_code` char(10) COLLATE utf8_unicode_ci DEFAULT NULL,
`country` varchar(2) COLLATE utf8_unicode_ci DEFAULT NULL,
`email` varchar(80) COLLATE utf8_unicode_ci NOT NULL,
`phone` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL,
`lang` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
`tts_engine` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`password` varchar(60) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'Encrypted password using the BCrypt algorithm',
`active` tinyint(1) DEFAULT '0',
`arasaac_license` tinyint(1) DEFAULT '0',
`role` enum('tutor','therapist','office','admin') COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `email` (`email`)
) ENGINE=InnoDB AUTO_INCREMENT=34 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Supervisors information';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `try`
--
DROP TABLE IF EXISTS `try`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `try` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_ws` int(11) NOT NULL,
`begin` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
`end` timestamp(3) NULL DEFAULT NULL,
`result` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL,
`description` varchar(4096) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `id_ws` (`id_ws`),
CONSTRAINT `try_ibfk_1` FOREIGN KEY (`id_ws`) REFERENCES `working_session` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='This table contains tries information (they belong to a working session)';
/*!40101 SET character_set_client = @saved_cs_client */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = latin1 */ ;
/*!50003 SET character_set_results = latin1 */ ;
/*!50003 SET collation_connection = latin1_swedish_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER TRG_NEW_TRY
AFTER INSERT ON try
FOR EACH ROW
thisTrigger: BEGIN
DECLARE idstu INT;
DECLARE idsup INT;
IF ((@TRIGGER_CHECKS = FALSE)
OR (@TRIGGER_AFTER_INSERT_CHECKS = FALSE))
AND (USER() = 'root@localhost')
THEN
LEAVE thisTrigger;
END IF;
SELECT DISTINCT M.id_stu,W.id_sup INTO idstu, idsup
FROM
instruction I,
method M,
working_session W
WHERE
NEW.id_ws=W.id AND
W.id_ins=I.id AND
I.id_met=M.id;
INSERT INTO stu_opentry(id_stu,id_sup,id_ws,id_opentry, total_tries,begin)
VALUES (
idstu,
idsup,
NEW.id_ws,
NEW.id,
0,
NOW(3)
)
ON DUPLICATE KEY UPDATE id_stu=idstu, id_sup=idsup, id_ws=NEW.id_ws, id_opentry=NEW.id;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = latin1 */ ;
/*!50003 SET character_set_results = latin1 */ ;
/*!50003 SET collation_connection = latin1_swedish_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER TRG_TRY_EVALUATED
AFTER UPDATE ON try
FOR EACH ROW
thisTrigger: BEGIN
DECLARE idws INT;
DECLARE ws_end DATE;
DECLARE ws_old_end DATE;
IF ((@TRIGGER_CHECKS = FALSE)
OR (@TRIGGER_AFTER_UPDATE_CHECKS = FALSE))
AND (USER() = 'root@localhost')
THEN
LEAVE thisTrigger;
END IF;
SELECT end INTO ws_end
FROM
stu_opentry
WHERE
id_ws = NEW.id_ws;
IF ( (old.result IS NULL) and (new.result IS NOT NULL) and (new.end>ws_end)) THEN
UPDATE stu_opentry
SET
end = new.end,
total_tries = total_tries + 1
WHERE
id_ws = NEW.id_ws;
END IF;
SELECT end INTO ws_old_end
FROM
working_session
WHERE
id = NEW.id_ws;
IF (ws_old_end < NEW.end) THEN
UPDATE working_session
SET end = NEW.end
WHERE id = NEW.id_ws;
END IF;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
--
-- Temporary table structure for view `v_stu_last_instruction`
--
DROP TABLE IF EXISTS `v_stu_last_instruction`;
/*!50001 DROP VIEW IF EXISTS `v_stu_last_instruction`*/;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `v_stu_last_instruction` AS SELECT
1 AS `id_ws`,
1 AS `ws_begin`,
1 AS `ws_end`,
1 AS `ws_description`,
1 AS `ins_name`,
1 AS `met_name`,
1 AS `id_stu`*/;
SET character_set_client = @saved_cs_client;
--
-- Temporary table structure for view `v_stu_last_ws_time`
--
DROP TABLE IF EXISTS `v_stu_last_ws_time`;
/*!50001 DROP VIEW IF EXISTS `v_stu_last_ws_time`*/;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `v_stu_last_ws_time` AS SELECT
1 AS `id_stu`,
1 AS `time`*/;
SET character_set_client = @saved_cs_client;
--
-- Table structure for table `working_session`
--
DROP TABLE IF EXISTS `working_session`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `working_session` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_sup` int(11) NOT NULL,
`id_ins` int(11) NOT NULL,
`begin` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
`end` timestamp(3) NULL DEFAULT NULL,
`current` tinyint(1) DEFAULT '1',
`description` varchar(4096) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `idx_ws_supcur` (`id_sup`,`current`),
KEY `id_sup` (`id_sup`),
KEY `id_ins` (`id_ins`),
CONSTRAINT `fk_ins_ws` FOREIGN KEY (`id_ins`) REFERENCES `instruction` (`id`),
CONSTRAINT `working_session_ibfk_1` FOREIGN KEY (`id_sup`) REFERENCES `supervisor` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='This table stores working session information. Every working session is related to one instruction and one supervisor (and the instruction is related to one method which is related to one student)';
/*!40101 SET character_set_client = @saved_cs_client */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = latin1 */ ;
/*!50003 SET character_set_results = latin1 */ ;
/*!50003 SET collation_connection = latin1_swedish_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER TRG_SESSION_NEW
AFTER INSERT ON working_session
FOR EACH ROW
thisTrigger: BEGIN
DECLARE idstu INT;
DECLARE ins_begin DATE;
IF ((@TRIGGER_CHECKS = FALSE)
OR (@TRIGGER_AFTER_INSERT_CHECKS = FALSE))
AND (USER() = 'root@localhost')
THEN
LEAVE thisTrigger;
END IF;
SELECT begin INTO ins_begin
FROM instruction
WHERE id = NEW.id_ins;
IF (ins_begin IS NULL) THEN
UPDATE instruction
SET
begin = NOW(3),
end = NOW(3)
WHERE
id = NEW.id_ins;
END IF;
UPDATE instruction
SET
status='started',
end = NOW(3)
WHERE
id = NEW.id_ins;
INSERT INTO try(`id_ws`)
VALUES (new.id);
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = latin1 */ ;
/*!50003 SET character_set_results = latin1 */ ;
/*!50003 SET collation_connection = latin1_swedish_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER TRG_SESSION_CLOSING
BEFORE UPDATE ON working_session
FOR EACH ROW
thisTrigger: BEGIN
IF ((@TRIGGER_CHECKS = FALSE)
OR (@TRIGGER_BEFORE_UPDATE_CHECKS = FALSE))
AND (USER() = 'root@localhost')
THEN
LEAVE thisTrigger;
END IF;
IF ((new.end IS NOT NULL) AND (new.current IS NOT NULL)) THEN
SET new.current=NULL;
END IF;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = latin1 */ ;
/*!50003 SET character_set_results = latin1 */ ;
/*!50003 SET collation_connection = latin1_swedish_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER TRG_SESSION_CLOSED
AFTER UPDATE ON working_session
FOR EACH ROW
thisTrigger: BEGIN
IF ((@TRIGGER_CHECKS = FALSE)
OR (@TRIGGER_AFTER_UPDATE_CHECKS = FALSE))
AND (USER() = 'root@localhost')
THEN
LEAVE thisTrigger;
END IF;
IF (OLD.end < NEW.end) THEN
UPDATE instruction
SET
end = NEW.end
WHERE
id = NEW.id_ins;
END IF;
IF ((old.end IS NULL) and (new.end IS NOT NULL)) THEN
CALL deleteOpenTry(new.id);
END IF;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
--
-- Final view structure for view `v_stu_last_instruction`
--
/*!50001 DROP VIEW IF EXISTS `v_stu_last_instruction`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
/*!50001 SET @saved_col_connection = @@collation_connection */;
/*!50001 SET character_set_client = utf8 */;
/*!50001 SET character_set_results = utf8 */;
/*!50001 SET collation_connection = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v_stu_last_instruction` AS select `WS`.`id` AS `id_ws`,`WS`.`begin` AS `ws_begin`,`WS`.`end` AS `ws_end`,`WS`.`description` AS `ws_description`,`I`.`name` AS `ins_name`,`M`.`name` AS `met_name`,`M`.`id_stu` AS `id_stu` from (((`working_session` `WS` join `instruction` `I`) join `method` `M`) join `v_stu_last_ws_time` `LAST_WS`) where ((`LAST_WS`.`time` = `WS`.`begin`) and (`LAST_WS`.`id_stu` = `M`.`id_stu`) and (`WS`.`id_ins` = `I`.`id`) and (`I`.`id_met` = `M`.`id`)) */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
--
-- Final view structure for view `v_stu_last_ws_time`
--
/*!50001 DROP VIEW IF EXISTS `v_stu_last_ws_time`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
/*!50001 SET @saved_col_connection = @@collation_connection */;
/*!50001 SET character_set_client = utf8 */;
/*!50001 SET character_set_results = utf8 */;
/*!50001 SET collation_connection = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v_stu_last_ws_time` AS select `M`.`id_stu` AS `id_stu`,max(`WS`.`begin`) AS `time` from ((`working_session` `WS` join `instruction` `I`) join `method` `M`) where ((`WS`.`id_ins` = `I`.`id`) and (`I`.`id_met` = `M`.`id`)) group by `M`.`id_stu` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2017-08-01 11:01:34
INSERT INTO `supervisor` VALUES (-1,'none','none','M','defaultAvatar.jpg',NULL,'',NULL,'',NULL,'es-es',NULL,'',0,0,'therapist'),(23,'Comunicación Aumentativa JAén (CAJA)','','M','test_caja_dofer.jpg',NULL,'23071',NULL,'dofer@ujaen.es','+34953212888','es-es',NULL,'$2a$10$Q4jHNlC58.ptfl/5wZeHfOIvpJslJHKOFNZO3bWs4it7TifQPQnEa',1,0,'office'),(24,'Miguel Ángel','García Cumbreras','M','test_caja_miguel.jpg',NULL,'23071',NULL,'magc@ujaen.es','+34953212420','es-es',NULL,'$2a$04$XQvWUwGTvjR47ChPwd3f6ukx8Zg.7o1N4Kf6P.zqhVtQxVNArOsXi',1,0,'therapist'),(25,'Arturo','Montejo Ráez','M','test_caja_arturo.jpg',NULL,'23071',NULL,'amontejo@ujaen.es','+34953212882','es-es',NULL,'$2a$04$yoBXAMSgCVGSIr2pnuIOw.J8UCm8f2XkATu5rqsMJiEmlxBHs5.cO',1,0,'therapist'),(26,'Alfonso','Ureña López','M','test_caja_alfonso.jpg',NULL,'23071',NULL,'laurena@ujaen.es','+34953212895','es-es',NULL,'$2a$04$zVGHJFafoZa60wo1yBqF/Oi3RXV/qS2cq0/j/W3Dkf4P1ad0e7.iS',1,0,'therapist'),(27,'Jesús','Navarro Moreno','M','defaultAvatar.jpg',NULL,'23071',NULL,'jnavarro@ujaen.es','+34953211912','es-es',NULL,'$2a$04$8O3Jd5j9/nM/KC.b1a8qRevyUwWUx6XGU3Gm754Y/8PpLO2jv.i76',1,0,'therapist'),(28,'Don Fernando','Padre Fernandito','M','defaultAvatar.jpg','C/ Mayor, 13. Jaén','23071','ES','donfernando@gmail.com','+34 232 232 232','es-es',NULL,'$2a$04$DMOX/cZ4h6cNJW9VlCou7O266q4YDYuS6p0QzP.gBHd08.QnFQWD.',1,0,'therapist'),(29,'Don Arturo','Padre Arturito','M','defaultAvatar.jpg','Avda. Andalucía 1. Jaén','23071','ES','donarturo@gmail.com',NULL,'es-es',NULL,'$2a$04$V2ods9MMmOFvdLTaHJqk3ejKEYdf28gvfDhaBkOSLCFJOC02TweFK',1,0,'therapist'),(30,'Don Miguel','Padre Miguelito','F','defaultAvatar.jpg','C/ Calatrava, 13. Córdoba','23071','ES','donmiguel@gmail.com',NULL,'es-es',NULL,'$2a$04$1UCak614LKz6WpDBtOblQeqFF41tOMy6ERMnP2OuGVZffe8Yi0mJq',1,0,'therapist'),(31,'Don Alfonso','Padre Alfonsito','M','defaultAvatar.jpg','Avda. Andalucía 1. Jaén','23071','ES','donalfonso@gmail.com',NULL,'es-es',NULL,'$2a$06$UtyBV4tLlT7xSqIt8LKPBucGvZ.Wgf7RgGE0fRcjEBDwjxjHlsP3K',1,0,'therapist'),(32,'Doña Alfonsa','Madre Alfonsita','F','defaultAvatar.jpg','C/ Calatrava, 13. Córdoba','23071','ES','doñaalfonsa@gmail.com',NULL,'es-es',NULL,'$2a$04$ALDmQ1oRhRZKUEi1b0eK1ehQmSZiFkhzx48ZBwER0J4vakvlYc5VS',1,0,'therapist'),(33,'Don Jesús','Padre Jesusito','M','defaultAvatar.jpg','Avda. Andalucía 1. Jaén','23071','ES','donjesus@gmail.com',NULL,'es-es',NULL,'$2a$04$Psuu6IMPUj1sbzR.uxq3EOgX1/4dFNmccjkv76LhKp35JzpiCE.fm',1,0,'therapist');
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
SET foreign_key_checks = 0;
SET @TRIGGER_CHECKS = FALSE;
--
-- Dumping data for table `supervisor`
--
LOCK TABLES `supervisor` WRITE;
/*!40000 ALTER TABLE `supervisor` DISABLE KEYS */;
INSERT INTO `supervisor` VALUES (-1,'none','none','M','defaultAvatar.jpg',NULL,'',NULL,'',NULL,'es-es',NULL,'',0,0,'tutor'),(23,'Comunicación Aumentativa JAén (CAJA)','','M','test_caja_dofer.jpg',NULL,'23071',NULL,'dofer@ujaen.es','+34953212888','es-es',NULL,'$2a$10$Q4jHNlC58.ptfl/5wZeHfOIvpJslJHKOFNZO3bWs4it7TifQPQnEa',1,0,'office'),(24,'Miguel Ángel','García Cumbreras','M','test_caja_miguel.jpg',NULL,'23071',NULL,'magc@ujaen.es','+34953212420','es-es',NULL,'$2a$04$XQvWUwGTvjR47ChPwd3f6ukx8Zg.7o1N4Kf6P.zqhVtQxVNArOsXi',1,0,'therapist'),(25,'Arturo','Montejo Ráez','M','test_caja_arturo.jpg',NULL,'23071',NULL,'amontejo@ujaen.es','+34953212882','es-es',NULL,'$2a$04$yoBXAMSgCVGSIr2pnuIOw.J8UCm8f2XkATu5rqsMJiEmlxBHs5.cO',1,0,'therapist'),(26,'Alfonso','Ureña López','M','test_caja_alfonso.jpg',NULL,'23071',NULL,'laurena@ujaen.es','+34953212895','es-es',NULL,'$2a$04$zVGHJFafoZa60wo1yBqF/Oi3RXV/qS2cq0/j/W3Dkf4P1ad0e7.iS',1,0,'therapist'),(27,'Jesús','Navarro Moreno','M','defaultAvatar.jpg',NULL,'23071',NULL,'jnavarro@ujaen.es','+34953211912','es-es',NULL,'$2a$04$8O3Jd5j9/nM/KC.b1a8qRevyUwWUx6XGU3Gm754Y/8PpLO2jv.i76',1,0,'therapist'),(28,'Don Fernando','Padre Fernandito','M','defaultAvatar.jpg','C/ Mayor, 13. Jaén','23071','ES','donfernando@gmail.com','+34 232 232 232','es-es',NULL,'$2a$04$DMOX/cZ4h6cNJW9VlCou7O266q4YDYuS6p0QzP.gBHd08.QnFQWD.',1,0,'tutor'),(29,'Don Arturo','Padre Arturito','M','defaultAvatar.jpg','Avda. Andalucía 1. Jaén','23071','ES','donarturo@gmail.com',NULL,'es-es',NULL,'$2a$04$V2ods9MMmOFvdLTaHJqk3ejKEYdf28gvfDhaBkOSLCFJOC02TweFK',1,0,'tutor'),(30,'Don Miguel','Padre Miguelito','F','defaultAvatar.jpg','C/ Calatrava, 13. Córdoba','23071','ES','donmiguel@gmail.com',NULL,'es-es',NULL,'$2a$04$1UCak614LKz6WpDBtOblQeqFF41tOMy6ERMnP2OuGVZffe8Yi0mJq',1,0,'tutor'),(31,'Don Alfonso','Padre Alfonsito','M','defaultAvatar.jpg','Avda. Andalucía 1. Jaén','23071','ES','donalfonso@gmail.com',NULL,'es-es',NULL,'$2a$06$UtyBV4tLlT7xSqIt8LKPBucGvZ.Wgf7RgGE0fRcjEBDwjxjHlsP3K',1,0,'tutor'),(32,'Doña Alfonsa','Madre Alfonsita','F','defaultAvatar.jpg','C/ Calatrava, 13. Córdoba','23071','ES','doñaalfonsa@gmail.com',NULL,'es-es',NULL,'$2a$04$ALDmQ1oRhRZKUEi1b0eK1ehQmSZiFkhzx48ZBwER0J4vakvlYc5VS',1,0,'tutor'),(33,'Don Jesús','Padre Jesusito','M','defaultAvatar.jpg','Avda. Andalucía 1. Jaén','23071','ES','donjesus@gmail.com',NULL,'es-es',NULL,'$2a$04$Psuu6IMPUj1sbzR.uxq3EOgX1/4dFNmccjkv76LhKp35JzpiCE.fm',1,0,'tutor');
/*!40000 ALTER TABLE `supervisor` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Dumping data for table `sup_off`
--
LOCK TABLES `sup_off` WRITE;
/*!40000 ALTER TABLE `sup_off` DISABLE KEYS */;
INSERT INTO `sup_off` VALUES (-1,NULL),(28,NULL),(29,NULL),(30,NULL),(31,NULL),(32,NULL),(33,NULL),(24,23),(25,23),(26,23),(27,23),(23,23);
INSERT INTO `sup_off` VALUES (-1,NULL),(28,NULL),(29,NULL),(30,NULL),(31,NULL),(32,NULL),(33,NULL),(23,23),(24,23),(25,23),(26,23),(27,23);
/*!40000 ALTER TABLE `sup_off` ENABLE KEYS */;
UNLOCK TABLES;
LOCK TABLES `stu_off` WRITE;
/*!40000 ALTER TABLE `stu_off` DISABLE KEYS */;
INSERT INTO `stu_off` VALUES (19,23),(20,23),(21,23),(22,23),(23,23),(24,23),(25,23),(26,23),(27,23),(28,23);
/*!40000 ALTER TABLE `stu_off` ENABLE KEYS */;
--
-- Dumping data for table `stu_sup`
--
LOCK TABLES `stu_sup` WRITE;
/*!40000 ALTER TABLE `stu_sup` DISABLE KEYS */;
INSERT INTO `stu_sup` VALUES (27,19,23),(30,19,28),(28,20,23),(48,21,23),(31,21,24),(35,21,30),(49,22,23),(32,22,24),(34,22,25),(29,23,23),(33,23,24),(36,23,25),(38,23,29),(26,24,23),(37,24,25),(39,24,27),(50,25,23),(44,25,26),(47,25,32),(51,26,23),(43,26,26),(46,26,31),(52,27,23),(41,27,27),(53,28,23),(45,28,26),(40,28,27),(42,28,33);
/*!40000 ALTER TABLE `stu_sup` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Dumping data for table `student`
--
LOCK TABLES `student` WRITE;
/*!40000 ALTER TABLE `student` DISABLE KEYS */;
INSERT INTO `student` VALUES (19,'faf0001','$2a$10$oy98CXG9YWbjATOESXelDu8HVjDHFPVpX5kmfdQSbkNC965Z2zPkC','Fernandito','Alumno Fernando','2009-12-10','M','ES','test_caja_juan.jpg',NULL,'es-es','{ \"categories\" : \"on\", \"input feedback\" : [ \"vibration\", \"tts\" ], \"input selection\" : \"click\", \"pictogram size\" : \"medium\", \"tts engine\" : \"IVONA Text-to-Speech HQ\", \"tts voice\": \"es\" }',1),(20,'faf0002','$2a$10$FOJ2fmJaHyI5sWe1tQojFuhoPpqHSTVPwvHPTpWEftFPI28VdyYNq','Fernandita','Alumna Fernando','2009-12-10','F','GB','test_caja_kate.jpg',NULL,'en-gb','{ \"categories\" : \"on\", \"input feedback\" : [ \"vibration\", \"tts\" ], \"input selection\" : \"click\", \"pictogram size\" : \"medium\", \"tts engine\" : \"IVONA Text-to-Speech HQ\", \"tts voice\": \"en\" }',3),(21,'mam0001','$2a$10$zygC/WviDviyZQsMsNqK8.tSUI4Qr/dLlLrw0i5kR1bbN4SeU5ACq','Miguelín','Alumno Miguel','2009-12-10','M','ES','test_caja_carlos.jpg',NULL,'es-es','{ \"categories\" : \"on\", \"input feedback\" : [ \"vibration\", \"tts\" ], \"input selection\" : \"click\", \"pictogram size\" : \"medium\", \"tts engine\" : \"IVONA Text-to-Speech HQ\", \"tts voice\": \"es\" }',5),(22,'mam0002','$2a$10$xbyNUhf9rqhdXDBrvUSiOuJIzUVOyyz9ToQMCByFThiiiPwO0PWgK','Miguelita','Alumna Miguel','2009-12-10','F','ES','test_caja_rocio.jpg',NULL,'es-es','{ \"categories\" : \"on\", \"input feedback\" : [ \"vibration\", \"tts\" ], \"input selection\" : \"click\", \"pictogram size\" : \"medium\", \"tts engine\" : \"IVONA Text-to-Speech HQ\", \"tts voice\": \"en\" }',7),(23,'aaa0001','$2a$10$koWKIn42UNSi1N67akxjpOuJNwpXJ/vOe6biD2xkjrUz6dr3g.Wa.','Arturito','Alumno Arturo','2009-12-10','M','ES','test_caja_samuel.jpg',NULL,'es-es','{ \"categories\" : \"on\", \"input feedback\" : [ \"vibration\", \"tts\" ], \"input selection\" : \"click\", \"pictogram size\" : \"medium\", \"tts engine\" : \"IVONA Text-to-Speech HQ\", \"tts voice\": \"es\" }',9),(24,'aaa0002','$2a$10$ffAjZjWN0UKja0JO7ko6qup4x2phbY3VpC66TmpMnGdWUutBFeWY2','Arturita','Alumna Arturo','2009-12-10','F','ES','test_caja_adela.jpg',NULL,'es-es','{ \"categories\" : \"on\", \"input feedback\" : [ \"vibration\", \"tts\" ], \"input selection\" : \"click\", \"pictogram size\" : \"medium\", \"tts engine\" : \"IVONA Text-to-Speech HQ\", \"tts voice\": \"en\" }',11),(25,'aaa0003','$2a$10$glc5A6vyPve5.4407Vdkau5CHF3GOpA0Uo6rxMDdIopIWTJK0nBse','Alfonsita','Alumna Alfonso','2009-12-10','F','ES','test_caja_adela.jpg',NULL,'es-es','{ \"categories\" : \"on\", \"input feedback\" : [ \"vibration\", \"tts\" ], \"input selection\" : \"click\", \"pictogram size\" : \"medium\", \"tts engine\" : \"IVONA Text-to-Speech HQ\", \"tts voice\": \"en\" }',13),(26,'aaa0004','$2a$10$tezK07jq5ZMdQbCboubEBeHiXWJisZPAbgN301n5kRLXkq8xOlb4O','Alfonsito','Alumno Alfonso','2009-12-10','M','ES','test_caja_juan.jpg',NULL,'es-es','{ \"categories\" : \"on\", \"input feedback\" : [ \"vibration\", \"tts\" ], \"input selection\" : \"click\", \"pictogram size\" : \"medium\", \"tts engine\" : \"IVONA Text-to-Speech HQ\", \"tts voice\": \"en\" }',15),(27,'jaj0001','$2a$10$UQYGXOOE8mxxOjvgo8cjwOpsv5jCtRXpMTLpbD3TzMBiUIv3hXlnO','Jesusita','Alumna Jesús','2009-12-10','F','ES','test_caja_adela.jpg',NULL,'es-es','{ \"categories\" : \"on\", \"input feedback\" : [ \"vibration\", \"tts\" ], \"input selection\" : \"click\", \"pictogram size\" : \"medium\", \"tts engine\" : \"IVONA Text-to-Speech HQ\", \"tts voice\": \"en\" }',17),(28,'jaj0002','$2a$10$tVy3Wfu35l4B6bFpnjJCE.ckjncq6YCKMGW4B9abesbiFVeyGu2Dy','Jesusito','Alumno Jesús','2009-12-10','M','ES','test_caja_samuel.jpg',NULL,'es-es','{ \"categories\" : \"on\", \"input feedback\" : [ \"vibration\", \"tts\" ], \"input selection\" : \"click\", \"pictogram size\" : \"medium\", \"tts engine\" : \"IVONA Text-to-Speech HQ\", \"tts voice\": \"en\" }',19);
INSERT INTO `student` VALUES (19,'faf0001','$2a$10$oy98CXG9YWbjATOESXelDu8HVjDHFPVpX5kmfdQSbkNC965Z2zPkC','Fernandito','Alumno Fernando','2009-12-10','M','ES','test_caja_juan.jpg',NULL,'es-es','{ \"categories\" : \"on\", \"input feedback\" : [ \"vibration\", \"tts\" ], \"input selection\" : \"click\", \"pictogram size\" : \"medium\", \"tts engine\" : \"IVONA Text-to-Speech HQ\", \"tts voice\": \"es\" }',NULL),(20,'faf0002','$2a$10$FOJ2fmJaHyI5sWe1tQojFuhoPpqHSTVPwvHPTpWEftFPI28VdyYNq','Fernandita','Alumna Fernando','2009-12-10','F','GB','test_caja_kate.jpg',NULL,'en-gb','{ \"categories\" : \"on\", \"input feedback\" : [ \"vibration\", \"tts\" ], \"input selection\" : \"click\", \"pictogram size\" : \"medium\", \"tts engine\" : \"IVONA Text-to-Speech HQ\", \"tts voice\": \"en\" }',NULL),(21,'mam0001','$2a$10$zygC/WviDviyZQsMsNqK8.tSUI4Qr/dLlLrw0i5kR1bbN4SeU5ACq','Miguelín','Alumno Miguel','2009-12-10','M','ES','test_caja_carlos.jpg',NULL,'es-es','{ \"categories\" : \"on\", \"input feedback\" : [ \"vibration\", \"tts\" ], \"input selection\" : \"click\", \"pictogram size\" : \"medium\", \"tts engine\" : \"IVONA Text-to-Speech HQ\", \"tts voice\": \"es\" }',NULL),(22,'mam0002','$2a$10$xbyNUhf9rqhdXDBrvUSiOuJIzUVOyyz9ToQMCByFThiiiPwO0PWgK','Miguelita','Alumna Miguel','2009-12-10','F','ES','test_caja_rocio.jpg',NULL,'es-es','{ \"categories\" : \"on\", \"input feedback\" : [ \"vibration\", \"tts\" ], \"input selection\" : \"click\", \"pictogram size\" : \"medium\", \"tts engine\" : \"IVONA Text-to-Speech HQ\", \"tts voice\": \"en\" }',NULL),(23,'aaa0001','$2a$10$koWKIn42UNSi1N67akxjpOuJNwpXJ/vOe6biD2xkjrUz6dr3g.Wa.','Arturito','Alumno Arturo','2009-12-10','M','ES','test_caja_samuel.jpg',NULL,'es-es','{ \"categories\" : \"on\", \"input feedback\" : [ \"vibration\", \"tts\" ], \"input selection\" : \"click\", \"pictogram size\" : \"medium\", \"tts engine\" : \"IVONA Text-to-Speech HQ\", \"tts voice\": \"es\" }',NULL),(24,'aaa0002','$2a$10$ffAjZjWN0UKja0JO7ko6qup4x2phbY3VpC66TmpMnGdWUutBFeWY2','Arturita','Alumna Arturo','2009-12-10','F','ES','test_caja_adela.jpg',NULL,'es-es','{ \"categories\" : \"on\", \"input feedback\" : [ \"vibration\", \"tts\" ], \"input selection\" : \"click\", \"pictogram size\" : \"medium\", \"tts engine\" : \"IVONA Text-to-Speech HQ\", \"tts voice\": \"en\" }',NULL),(25,'aaa0003','$2a$10$glc5A6vyPve5.4407Vdkau5CHF3GOpA0Uo6rxMDdIopIWTJK0nBse','Alfonsita','Alumna Alfonso','2009-12-10','F','ES','test_caja_adela.jpg',NULL,'es-es','{ \"categories\" : \"on\", \"input feedback\" : [ \"vibration\", \"tts\" ], \"input selection\" : \"click\", \"pictogram size\" : \"medium\", \"tts engine\" : \"IVONA Text-to-Speech HQ\", \"tts voice\": \"en\" }',NULL),(26,'aaa0004','$2a$10$tezK07jq5ZMdQbCboubEBeHiXWJisZPAbgN301n5kRLXkq8xOlb4O','Alfonsito','Alumno Alfonso','2009-12-10','M','ES','test_caja_juan.jpg',NULL,'es-es','{ \"categories\" : \"on\", \"input feedback\" : [ \"vibration\", \"tts\" ], \"input selection\" : \"click\", \"pictogram size\" : \"medium\", \"tts engine\" : \"IVONA Text-to-Speech HQ\", \"tts voice\": \"en\" }',NULL),(27,'jaj0001','$2a$10$UQYGXOOE8mxxOjvgo8cjwOpsv5jCtRXpMTLpbD3TzMBiUIv3hXlnO','Jesusita','Alumna Jesús','2009-12-10','F','ES','test_caja_adela.jpg',NULL,'es-es','{ \"categories\" : \"on\", \"input feedback\" : [ \"vibration\", \"tts\" ], \"input selection\" : \"click\", \"pictogram size\" : \"medium\", \"tts engine\" : \"IVONA Text-to-Speech HQ\", \"tts voice\": \"en\" }',NULL),(28,'jaj0002','$2a$10$tVy3Wfu35l4B6bFpnjJCE.ckjncq6YCKMGW4B9abesbiFVeyGu2Dy','Jesusito','Alumno Jesús','2009-12-10','M','ES','test_caja_samuel.jpg',NULL,'es-es','{ \"categories\" : \"on\", \"input feedback\" : [ \"vibration\", \"tts\" ], \"input selection\" : \"click\", \"pictogram size\" : \"medium\", \"tts engine\" : \"IVONA Text-to-Speech HQ\", \"tts voice\": \"en\" }',NULL);
/*!40000 ALTER TABLE `student` ENABLE KEYS */;
UNLOCK TABLES;
SET @TRIGGER_CHECKS = TRUE;
SET foreign_key_checks=1;
......@@ -15,13 +15,6 @@ ALTER TABLE student MODIFY gender CHAR(1) DEFAULT NULL;
ALTER TABLE student MODIFY country CHAR(2) DEFAULT NULL;
ALTER TABLE student MODIFY lang VARCHAR(5) DEFAULT NULL;
CREATE TABLE IF NOT EXISTS stu_off (
id_stu int(11) NOT NULL,
id_off int(11) DEFAULT NULL,
CONSTRAINT fk_stu_off FOREIGN KEY (id_stu) REFERENCES student (id),
CONSTRAINT fk_off_stu FOREIGN KEY (id_off) REFERENCES supervisor (id)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE IF NOT EXISTS sup_off (
id_sup int(11) NOT NULL,
id_off int(11) DEFAULT NULL,
......@@ -38,6 +31,10 @@ UPDATE supervisor
SET role = 'therapist'
WHERE id NOT IN (SELECT admin FROM office WHERE admin IS NOT NULL);
UPDATE supervisor
SET role = 'tutor'
WHERE id_off IS NULL;
DELIMITER $$
DROP PROCEDURE IF EXISTS supervisor_adapt $$
CREATE PROCEDURE supervisor_adapt()
......@@ -75,8 +72,8 @@ BEGIN
DELIMITER ;
CALL supervisor_adapt();
INSERT INTO stu_off (id_stu, id_off)
SELECT id, id_off
INSERT IGNORE INTO stu_sup (id_stu,id_sup)
SELECT id,id_off
FROM student;
INSERT INTO sup_off (id_sup, id_off)
......@@ -90,4 +87,3 @@ ALTER TABLE supervisor DROP FOREIGN KEY supervisor_ibfk_1;
ALTER TABLE supervisor DROP COLUMN id_off;
DROP TABLE office;
# Changes
#Database changes
SET foreign_key_checks = 0;
#Add role column
ALTER TABLE supervisor ADD role enum('tutor','therapist','office','admin') NOT NULL;
#Add nullable to table supervisor
ALTER TABLE supervisor MODIFY name VARCHAR(40) DEFAULT NULL;
ALTER TABLE supervisor MODIFY surname VARCHAR(60) DEFAULT NULL;
ALTER TABLE supervisor MODIFY gender CHAR(1) DEFAULT NULL;
ALTER TABLE supervisor MODIFY postal_code CHAR(10) DEFAULT NULL;
ALTER TABLE supervisor MODIFY lang VARCHAR(5) DEFAULT NULL;
#Add nullable to table student
ALTER TABLE student MODIFY name VARCHAR(40) DEFAULT NULL;
ALTER TABLE student MODIFY surname VARCHAR(60) DEFAULT NULL;
ALTER TABLE student MODIFY birthdate DATE DEFAULT NULL;
ALTER TABLE student MODIFY gender CHAR(1) DEFAULT NULL;
ALTER TABLE student MODIFY country CHAR(2) DEFAULT NULL;
ALTER TABLE student MODIFY lang VARCHAR(5) DEFAULT NULL;
#Create the tables
CREATE TABLE IF NOT EXISTS stu_off (
id_stu int(11) NOT NULL,
id_off int(11) DEFAULT NULL,
CONSTRAINT fk_stu_off FOREIGN KEY (id_stu) REFERENCES student (id),
CONSTRAINT fk_off_stu FOREIGN KEY (id_off) REFERENCES supervisor (id)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE IF NOT EXISTS sup_off (
id_sup int(11) NOT NULL,
id_off int(11) DEFAULT NULL,
CONSTRAINT fk_sup_off FOREIGN KEY (id_sup) REFERENCES supervisor (id),
CONSTRAINT fk_off_sup FOREIGN KEY (id_off) REFERENCES supervisor (id)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
#Update roles
UPDATE supervisor
SET role = 'office'
WHERE id IN (SELECT admin FROM office WHERE admin IS NOT NULL);
UPDATE supervisor
SET role = 'therapist'
WHERE id NOT IN (SELECT admin FROM office WHERE admin IS NOT NULL);
#Insert the offices into supervisor table and change the elements of the table stu_sup
DELIMITER $$
DROP PROCEDURE IF EXISTS supervisor_adapt $$
CREATE PROCEDURE supervisor_adapt()
BEGIN
DECLARE done INT DEFAULT FALSE;
DECLARE id_admin INT;
DECLARE id_off_actual INT;
DECLARE name_sup VARCHAR(80);
DECLARE office CURSOR FOR SELECT id,name,admin FROM pictodb.office;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
OPEN office;
read_loop: LOOP
FETCH office INTO id_off_actual,name_sup,id_admin;
IF done THEN
LEAVE read_loop;
END IF;
UPDATE supervisor SET name = name_sup, surname = '',role = 'office'
WHERE id = id_admin;
UPDATE student SET id_off = id_admin WHERE id_off = id_off_actual;
UPDATE supervisor SET id_off = id_admin WHERE id_off = id_off_actual;
END LOOP;
CLOSE office;
END $$
DELIMITER ;
CALL supervisor_adapt();
#Insert into stu_off
INSERT INTO stu_off (id_stu, id_off)
SELECT id, id_off
FROM student;
#Insert into sup_off
INSERT INTO sup_off (id_sup, id_off)
SELECT id, id_off
FROM supervisor;
#Delete id_off column from student and supervisor
ALTER TABLE student DROP FOREIGN KEY student_ibfk_1;
ALTER TABLE student DROP COLUMN id_off;
ALTER TABLE supervisor DROP FOREIGN KEY supervisor_ibfk_1;
ALTER TABLE supervisor DROP COLUMN id_off;
#Delete office table
DROP TABLE office;
#Para actualizar instalaciones antiguas ejecutar en vagrant/roles/database/files
# mysql -u root -p pictodb < upgrade.sql
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment