Issue #284 done, CHANGES.md modified

parent 43136947
-- phpMyAdmin SQL Dump
-- version 4.1.14
-- http://www.phpmyadmin.net
-- MySQL dump 10.13 Distrib 5.7.19, for Linux (x86_64)
--
-- Servidor: 127.0.0.1
-- Tiempo de generación: 11-03-2015 a las 03:31:50
-- Versión del servidor: 5.6.17
-- Versión de PHP: 5.5.12
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
-- 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 */;
--
-- Base de datos: `pictodb`
--
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `action`
-- Table structure for table `action`
--
CREATE TABLE IF NOT EXISTS `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 CHECK (type IN ('Add','Select','Delete','Show','Unshow','Pause','tryinit','tryend','initsession','endsession','pausesession','resumesession')),
`timestamp` timestamp(3) DEFAULT CURRENT_TIMESTAMP(3),
`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,
......@@ -35,19 +33,143 @@ CREATE TABLE IF NOT EXISTS `action` (
`gps_lat` float DEFAULT NULL,
`gps_lon` float DEFAULT NULL,
PRIMARY KEY (`id`),
CONSTRAINT uq_stuact UNIQUE (id_stu,timestamp),
CONSTRAINT uq_supact UNIQUE (id_sup,timestamp),
UNIQUE (id_stu,timestamp),
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`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1
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.";
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 */ ;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `catexp`
-- 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,
......@@ -56,112 +178,119 @@ CREATE TABLE `catexp` (
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 */;
--
-- Estructura de tabla para la tabla `method`
-- Table structure for table `instruction`
--
CREATE TABLE IF NOT EXISTS `method` (
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,
`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,
`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_stu_met` (`id_stu`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1
COMMENT="Information for a method. A method is composed by a set of instructions";
-- --------------------------------------------------------
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 */;
--
-- Estructura de tabla para la tabla `instruction`
-- Table structure for table `license`
--
CREATE TABLE IF NOT EXISTS `instruction` (
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_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 CHECK (status IN ('started','finished')),
`begin` timestamp(3) NULL,
`end` timestamp(3) NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1
COMMENT="An instruction is a 'phase' in a method for learning AAC";
-- CREATE INDEX ix_instruction_begin ON instruction (`begin`);
-- --------------------------------------------------------
`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 */;
--
-- Estructura de tabla para la tabla `meta_instruction`
-- Table structure for table `meta_instruction`
--
CREATE TABLE IF NOT EXISTS `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`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1
COMMENT="One in a set of instructions predefined or stored by users. They are related to a metamethod (id_met)";
-- --------------------------------------------------------
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 */;
--
-- Estructura de tabla para la tabla `meta_method`
-- Table structure for table `meta_method`
--
CREATE TABLE IF NOT EXISTS `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,
`id_sup` int(11) DEFAULT NULL,
`lang` char(5) COLLATE utf8_unicode_ci NOT NULL,
UNIQUE(name,id_sup),
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1
COMMENT="Methods predefined in the platform or stored by users for cloning";
-- --------------------------------------------------------
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 */;
--
-- Estructura de tabla para la tabla `office`
-- Table structure for table `method`
--
CREATE TABLE IF NOT EXISTS `office` (
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(80) COLLATE utf8_unicode_ci NOT NULL,
`logo_url` varchar(240) COLLATE utf8_unicode_ci NOT NULL,
`address` varchar(180) COLLATE utf8_unicode_ci NOT NULL,
`postal_code` char(10) COLLATE utf8_unicode_ci NOT NULL,
`country` varchar(2) COLLATE utf8_unicode_ci NOT NULL,
`lang` varchar(5) COLLATE utf8_unicode_ci NOT NULL,
`contact_person` varchar(80) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Contact person, main responsible',
`email` varchar(80) COLLATE utf8_unicode_ci NOT NULL,
`phone1` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
`phone2` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL,
`admin` int(11) DEFAULT NULL COMMENT 'Teacher administrator, able to associate students to teachers',
`max_students` int(4) DEFAULT 10 COMMENT 'Maximun number of enrolments for a given office',
`current_students` int(4) DEFAULT 0 COMMENT 'calculable attr: current number of enrolments',
`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`),
UNIQUE KEY `email` (`email`),
KEY `fk_admin_tea` (`admin`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=383
COMMENT="Information about a therapists' office (cabinet)";
-- --------------------------------------------------------
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 */;
--
-- Estructura de tabla para la tabla `picto`
-- Table structure for table `picto`
--
CREATE TABLE IF NOT EXISTS `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,
......@@ -170,80 +299,77 @@ CREATE TABLE IF NOT EXISTS `picto` (
PRIMARY KEY (`id`),
UNIQUE KEY `ck_pic` (`id_owner`,`id_src`,`uri`),
KEY `fk_sou_pic` (`id_src`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=104142
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)";
) 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 */;
--
-- Estructura de tabla para la tabla `picto_acl`
-- NOT IN USE (candidate for removal)
-- Table structure for table `picto_acl`
--
CREATE TABLE IF NOT EXISTS `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),
`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`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1
COMMENT="Stablish access rights to pictos";
-- --------------------------------------------------------
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 */;
--
-- Estructura de tabla para la tabla `pictocat`
-- Table structure for table `picto_core`
--
CREATE TABLE IF NOT EXISTS `pictocat`(
`id` int(11) PRIMARY KEY,
`id_supercat` int(11) DEFAULT NULL
)
ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT="Identifies a category, which, itself, may belong to another category";
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `picto_core`
--
CREATE TABLE IF NOT EXISTS `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) NULL, -- 9 for a #RRGGBBAA color
`color` varchar(9) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `id_pic` (`id_pic`),
KEY `id_cat_pic` (`id_cat_pic`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=124
COMMENT="Default pictos and categories available for a newly created student with default coordinates";
-- --------------------------------------------------------
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 */;
--
-- Estructura de tabla para la tabla `picto_exp`
-- Table structure for table `picto_exp`
--
CREATE TABLE IF NOT EXISTS `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 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=72565
COMMENT="Expression (text label) for a picto (or a category) in different languages. This is used by the TTS engine";
-- --------------------------------------------------------
) 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 */;
--
-- Estructura de tabla para la tabla `picto_tag`
-- Table structure for table `picto_tag`
--
CREATE TABLE IF NOT EXISTS `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,
......@@ -251,80 +377,130 @@ CREATE TABLE IF NOT EXISTS `picto_tag` (
`lang` char(5) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`),
KEY `id_pic` (`id_pic`),
KEY `id_sup` (`id_sup`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1
COMMENT="Labels assigned to pictos by default or by supervisors";
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 */;
--
-- Estructura de tabla para la tabla `source`
-- Table structure for table `source`
--
CREATE TABLE IF NOT EXISTS `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 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=2
COMMENT="Contains all possible sources of pictos";
-- --------------------------------------------------------
) 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 */;
--
-- Estructura de tabla para la tabla `student`
-- Table structure for table `stu_off`
--
CREATE TABLE IF NOT EXISTS `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 NOT NULL,
`surname` varchar(60) COLLATE utf8_unicode_ci NOT NULL,
`birthdate` date NOT NULL,
`gender` char(1) COLLATE utf8_unicode_ci NOT NULL,
`country` char(2) COLLATE utf8_unicode_ci NOT 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 NOT NULL,
`attributes` varchar(4096) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Attributes describing student along with his/her configuration',
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,
`id_active_scene` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `username` (`username`),
KEY `id_off` (`id_off`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=19
COMMENT="Students information";
-- --------------------------------------------------------
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 */;
--
-- Estructura de tabla para la tabla `license`
-- Table structure for table `stu_opentry`
--
CREATE TABLE IF NOT EXISTS `license` (
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) DEFAULT NULL,
`number` varchar(16) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`creation_ts` datetime DEFAULT CURRENT_TIMESTAMP,
`activation_ts` datetime NULL,
`expiration_ts` datetime NULL,
`duration` int(11) DEFAULT 0,
`creator` varchar(40) DEFAULT NULL,
`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 `number` (`number`),
KEY `id_stu` (`id_stu`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=19
COMMENT="Student license number";
-- --------------------------------------------------------
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 */;
--
-- Estructura de tabla para la tabla `stu_picto`
-- Table structure for table `stu_picto`
--
CREATE TABLE IF NOT EXISTS `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,
......@@ -332,314 +508,537 @@ CREATE TABLE IF NOT EXISTS `stu_picto` (
`id_scene` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `fk_picto` (`id_pic`),
KEY `id_stu` (`id_stu`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1
COMMENT="This table relates a student with the pictos in her vocabulary";
-- --------------------------------------------------------
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 */;
--
-- Estructura de tabla para la tabla `stu_sup`
-- Table structure for table `stu_sup`
--
CREATE TABLE IF NOT EXISTS `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`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=26
COMMENT="This table relates students and supervisors";
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 */;
--
-- Estructura de tabla para la tabla `supervisor`
-- Table structure for table `supervisor`
--
CREATE TABLE IF NOT EXISTS `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 NOT NULL,
`surname` varchar(60) COLLATE utf8_unicode_ci NOT NULL,
`gender` char(1) COLLATE utf8_unicode_ci NOT NULL,
`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 NOT 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 NOT 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',
`id_off` int(11) DEFAULT NULL,
`active` boolean DEFAULT FALSE,
`arasaac_license` boolean DEFAULT FALSE,
`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`),
KEY `id_off` (`id_off`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=23
COMMENT="Supervisors information";
-- --------------------------------------------------------
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 */;
--
-- Estructura de tabla para la tabla `try`
-- Table structure for table `try`
--
CREATE TABLE IF NOT EXISTS `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) DEFAULT CURRENT_TIMESTAMP(3),
`end` timestamp(3) NULL,
`result` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL CHECK (result IN ('SUCCESS','SPONTANEUS SUCCESS', 'SUPERVISED SUCCESS', 'FAIL','DISCARDED','MODEL')),
`description` varchar(4096) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `id_ws` (`id_ws`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1
COMMENT="This table contains tries information (they belong to a working session)";
-- CREATE INDEX ix_try_begin ON try (`begin`);
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `working_session`
--
-- NOTA: current es un atributo derivado que es necesario porque MySQL 5.1
-- no soporta correctamente indices con valor unico donde un campo es NULL
-- Trabaja en combinación al índice unico (id_sup,current) (idx_ws_supcur)
--
CREATE TABLE IF NOT EXISTS `working_session` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_sup` int(11) NOT NULL,
`id_ins` int(11) NOT NULL,
`begin` timestamp(3) DEFAULT CURRENT_TIMESTAMP(3),
`end` timestamp(3) NULL,
`current` boolean NULL DEFAULT 1,
`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_sup` (`id_sup`),
KEY `id_ins` (`id_ins`),
-- Integrity rule 6: It is not possible to open a new session when a previous session is opened for a given supervisor
-- when: state SES and PAU, event a2
-- (see triggers-sessions-integrity-constraints for the rest of rules)
--
CONSTRAINT `idx_ws_supcur` UNIQUE (id_sup, current)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1
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)";
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `scene`
--
CREATE TABLE IF NOT EXISTS `scene` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`categories` boolean NOT NULL DEFAULT 0,
`id_sup` int(11) DEFAULT NULL,
`id_stu` int(11) NOT NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (`id_sup`) REFERENCES `supervisor` (`id`),
FOREIGN KEY (`id_stu`) REFERENCES `student` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1
COMMENT="Scene table information. Every scene is related to some stu_pictos";
-- CREATE INDEX ix_ws_begin ON working_session (`begin`);
--
-- Restricciones para tablas volcadas
--
--
-- Filtros para la tabla `action`
--
ALTER TABLE `action`
ADD CONSTRAINT `fk_stu_act` FOREIGN KEY (`id_stu`) REFERENCES `student` (`id`),
ADD CONSTRAINT `fk_sup_act` FOREIGN KEY (`id_sup`) REFERENCES `supervisor` (`id`);
-- Integrity rule 8: Every action requires a valid try or null
-- when: state SES, event a3 and a5
-- (see triggers-sessions-integrity-constraints for the rest of rules)
--
ALTER TABLE `action`
ADD CONSTRAINT `fk_try_act` FOREIGN KEY (`id_try`) REFERENCES `try` (`id`) ON DELETE SET NULL;;
--
-- Filtros para la tabla `method`
--
ALTER TABLE `method`
ADD CONSTRAINT `fk_stu_met` FOREIGN KEY (`id_stu`) REFERENCES `student` (`id`);
--
-- Filtros para la tabla `instruction`
--
ALTER TABLE `instruction`
ADD CONSTRAINT `fk_met_ins` FOREIGN KEY (`id_met`) REFERENCES `method` (`id`);
--
-- Filtros para la tabla `meta_instruction`
--
ALTER TABLE `meta_instruction`
ADD CONSTRAINT `fk_ins_met` FOREIGN KEY (`id_met`) REFERENCES `meta_method` (`id`);
--
-- Filtros para la tabla `meta_method`
--
ALTER TABLE `meta_method`
ADD CONSTRAINT `fk_met_sup` FOREIGN KEY (`id_sup`) REFERENCES `supervisor` (`id`);
--
-- Filtros para la tabla `office`
--
ALTER TABLE `office`
ADD CONSTRAINT `office_ibfk_1` FOREIGN KEY (`admin`) REFERENCES `supervisor` (`id`);
--
-- Filtros para la tabla `picto`
--
--
-- Filtros para la tabla `picto_acl`
--
ALTER TABLE `picto_acl`
ADD CONSTRAINT `fk_pic_aclp` FOREIGN KEY (`id_pic`) REFERENCES `picto` (`id`),
ADD CONSTRAINT `fk_sup_aclp` FOREIGN KEY (`id_sup`) REFERENCES `supervisor` (`id`);
--
-- Filtros para la tabla `picto_core_cat`
--
ALTER TABLE `picto_core`
ADD CONSTRAINT `picto_core_ibfk_1` FOREIGN KEY (`id_cat_pic`) REFERENCES `picto` (`id`),
ADD CONSTRAINT `picto_core_ibfk_2` FOREIGN KEY (`id_pic`) REFERENCES `picto` (`id`);
--
-- Filtros para la tabla `picto_tag`
--
ALTER TABLE `picto_tag`
ADD CONSTRAINT `fk_con_pt` FOREIGN KEY (`id_pic`) REFERENCES `picto` (`id`);
--
-- Filtros para la tabla `picto_tag_sup`
--
ALTER TABLE `picto_tag`
ADD CONSTRAINT `picto_tag_ibfk_1` FOREIGN KEY (`id_sup`) REFERENCES `supervisor` (`id`),
ADD CONSTRAINT `picto_tag_ibfk_2` FOREIGN KEY (`id_pic`) REFERENCES `picto` (`id`);
--
-- Filtros para la tabla `stu_picto`
--
ALTER TABLE `stu_picto`
ADD CONSTRAINT `fk_picto` FOREIGN KEY (`id_pic`) REFERENCES `picto` (`id`),
ADD CONSTRAINT `stu_picto_ibfk_1` FOREIGN KEY (`id_stu`) REFERENCES `student` (`id`),
ADD CONSTRAINT `stu_picto_scene_fk` FOREIGN KEY (`id_scene`) REFERENCES `scene` (`id`) ON DELETE CASCADE;
--
-- Filtros para la tabla `stu_sup`
--
ALTER TABLE `stu_sup`
ADD CONSTRAINT `stu_sup_ibfk_1` FOREIGN KEY (`id_stu`) REFERENCES `student` (`id`) ON DELETE CASCADE,
ADD CONSTRAINT `stu_sup_ibfk_2` FOREIGN KEY (`id_sup`) REFERENCES `supervisor` (`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;
--
-- Filtros para la tabla `student`
--
ALTER TABLE `student`
ADD CONSTRAINT `student_ibfk_1` FOREIGN KEY (`id_off`) REFERENCES `office` (`id`);
IF (ws_old_end < NEW.end) THEN
UPDATE working_session
SET end = NEW.end
WHERE id = NEW.id_ws;
END IF;
--
-- Filtros para la tabla `license`
--
ALTER TABLE `license`
ADD CONSTRAINT `license_fk_1` FOREIGN KEY (`id_stu`) REFERENCES `student` (`id`) ON DELETE CASCADE;
--
-- Filtros para la tabla `supervisor`
--
ALTER TABLE `supervisor`
ADD CONSTRAINT `supervisor_ibfk_1` FOREIGN KEY (`id_off`) REFERENCES `office` (`id`);
--
-- Filtros para la tabla `try`
--
ALTER TABLE `try`
ADD CONSTRAINT `try_ibfk_1` FOREIGN KEY (`id_ws`) REFERENCES `working_session` (`id`) ON DELETE CASCADE;
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 */ ;
--
-- Filtros para la tabla `working_session`
-- Temporary table structure for view `v_stu_last_instruction`
--
ALTER TABLE `working_session`
ADD CONSTRAINT `fk_ins_ws` FOREIGN KEY (`id_ins`) REFERENCES `instruction` (`id`),
ADD CONSTRAINT `working_session_ibfk_1` FOREIGN KEY (`id_sup`) REFERENCES `supervisor` (`id`);
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;
--
-- Estructura para la vista `v_stu_last_instruction`
-- Temporary table structure for view `v_stu_last_ws_time`
--
CREATE ALGORITHM=UNDEFINED
VIEW `v_stu_last_ws_time` AS
SELECT M.`id_stu` AS id_stu,
MAX(WS.begin) AS time
FROM
`working_session` AS WS join
`instruction` AS I join
`method` AS M
WHERE
WS.`id_ins` =I.`id`
and I.`id_met` = M.`id`
group by M.`id_stu`;
CREATE ALGORITHM=UNDEFINED
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` AS WS join
`instruction` AS I join
`method` AS M join
`v_stu_last_ws_time` AS 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`;
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;
--
-- VIEW `v_stu_last_instruction`
-- Datos: Ninguna
-- Table structure for table `working_session`
--
--
-- Vista materializada mv_stu_last_working_session_detail
-- Mantenida por
-- Utilizada por SAILS:StudentController.lasttries
--
--
-- CREATE TABLE mv_stu_last_working_session_detail IF NOT EXISTS `mv_stu_last_working_session_detail` (
-- `id` int(11) NOT NULL AUTO_INCREMENT,
-- PRIMARY KEY (`id`),
-- KEY `id_sup` (`id_sup`),
-- KEY `id_ins` (`id_ins`)
-- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
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
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
SET foreign_key_checks = 0;
SET @TRIGGER_CHECKS = FALSE;
--
-- Oficina
--
INSERT INTO `office` (
`name`,
`address`,
`country`,
`contact_person`,
`email`,
`phone1`,
`lang`,
`postal_code`
) VALUES (
'Comunicación Aumentativa JAén (CAJA)',
'Paraje Las Lagunillas, Ed A3, primera plata, 23071. Jaén',
'ES',
'Fernando Martínez Santiago',
'dofer@ujaen.es',
'+34 953 21 28 88',
'es-es',
'23071'
);
--
-- Supervisores
--
INSERT INTO `supervisor` (
`name`,
`surname`,
`gender`,
`address`,
`email`,
`phone`,
`lang`,
`password`,
`active`,
`postal_code`,
`id_off`,
`pic`
) VALUES (
'Fernando',
'Martínez Santiago',
'M',
NULL,
'dofer@ujaen.es',
'+34953212888',
'es-es',
'$2a$10$Q4jHNlC58.ptfl/5wZeHfOIvpJslJHKOFNZO3bWs4it7TifQPQnEa',
true,
'23071',
(SELECT id from office where email='dofer@ujaen.es'),
'test_caja_dofer.jpg'
), (
'Miguel Ángel',
'García Cumbreras',
'M',
NULL,
'magc@ujaen.es',
'+34953212420',
'es-es',
'$2a$04$XQvWUwGTvjR47ChPwd3f6ukx8Zg.7o1N4Kf6P.zqhVtQxVNArOsXi',
true,
'23071',
(SELECT id from office where email='dofer@ujaen.es'),
'test_caja_miguel.jpg'
), (
'Arturo',
'Montejo Ráez',
'M',
NULL,
'amontejo@ujaen.es',
'+34953212882',
'es-es',
'$2a$04$yoBXAMSgCVGSIr2pnuIOw.J8UCm8f2XkATu5rqsMJiEmlxBHs5.cO',
true,
'23071',
(SELECT id from office where email='dofer@ujaen.es'),
'test_caja_arturo.jpg'
), (
'Alfonso',
'Ureña López',
'M',
NULL,
'laurena@ujaen.es',
'+34953212895',
'es-es',
'$2a$04$zVGHJFafoZa60wo1yBqF/Oi3RXV/qS2cq0/j/W3Dkf4P1ad0e7.iS',
true,
'23071',
(SELECT id from office where email='dofer@ujaen.es'),
'test_caja_alfonso.jpg'
), (
'Jesús',
'Navarro Moreno',
'M',
NULL,
'jnavarro@ujaen.es',
'+34953211912',
'es-es',
'$2a$04$8O3Jd5j9/nM/KC.b1a8qRevyUwWUx6XGU3Gm754Y/8PpLO2jv.i76',
true,
'23071',
(SELECT id from office where email='dofer@ujaen.es'),
'defaultAvatar.jpg'
);
--
-- Tutores
--
INSERT INTO `supervisor` (
`name`,
`surname`,
`gender`,
`address`,
`country`,
`email`,
`phone`,
`lang`,
`password`,
`active`,
`postal_code`
) VALUES (
'Don Fernando',
'Padre Fernandito',
'M',
'C/ Mayor, 13. Jaén',
'ES',
'donfernando@gmail.com',
'+34 232 232 232',
'es-es',
'$2a$04$DMOX/cZ4h6cNJW9VlCou7O266q4YDYuS6p0QzP.gBHd08.QnFQWD.',
true,
'23071'
), (
'Don Arturo',
'Padre Arturito',
'M',
'Avda. Andalucía 1. Jaén',
'ES',
'donarturo@gmail.com',
NULL,
'es-es',
'$2a$04$V2ods9MMmOFvdLTaHJqk3ejKEYdf28gvfDhaBkOSLCFJOC02TweFK',
true,
'23071'
), (
'Don Miguel',
'Padre Miguelito',
'F',
'C/ Calatrava, 13. Córdoba',
'ES',
'donmiguel@gmail.com',
NULL,
'es-es',
'$2a$04$1UCak614LKz6WpDBtOblQeqFF41tOMy6ERMnP2OuGVZffe8Yi0mJq',
true,
'23071'
), (
'Don Alfonso',
'Padre Alfonsito',
'M',
'Avda. Andalucía 1. Jaén',
'ES',
'donalfonso@gmail.com',
NULL,
'es-es',
'$2a$06$UtyBV4tLlT7xSqIt8LKPBucGvZ.Wgf7RgGE0fRcjEBDwjxjHlsP3K',
true,
'23071'
), (
'Doña Alfonsa',
'Madre Alfonsita',
'F',
'C/ Calatrava, 13. Córdoba',
'ES',
'doñaalfonsa@gmail.com',
NULL,
'es-es',
'$2a$04$ALDmQ1oRhRZKUEi1b0eK1ehQmSZiFkhzx48ZBwER0J4vakvlYc5VS',
true,
'23071'
), (
'Don Jesús',
'Padre Jesusito',
'M',
'Avda. Andalucía 1. Jaén',
'ES',
'donjesus@gmail.com',
NULL,
'es-es',
'$2a$04$Psuu6IMPUj1sbzR.uxq3EOgX1/4dFNmccjkv76LhKp35JzpiCE.fm',
true,
'23071'
);
--
-- Actualización de `office` con el id del supervisor admin
--
UPDATE office
SET admin=(SELECT id FROM supervisor where email='dofer@ujaen.es')
WHERE email='dofer@ujaen.es';
--
-- CAJA Students
--
INSERT INTO `student` (
`username`,
`password`,
`name`,
`surname`,
`birthdate`,
`gender`,
`country`,
`pic`,
`notes`,
`lang`,
`attributes`
) VALUES (
'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" }'
), (
'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" }'
), (
'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" }'
), (
'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" }'
), (
'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" }'
), (
'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" }'
), (
'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" }'
), (
'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" }'
), (
'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" }'
), (
'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" }'
);
--
-- CAJA student-supervisor
--
INSERT INTO `stu_sup` (
id_stu,
id_sup
) VALUES (
(SELECT id FROM student WHERE username='aaa0002'),
(SELECT id FROM supervisor WHERE email='dofer@ujaen.es')
);
INSERT INTO `stu_sup`(id_stu,id_sup) SELECT DISTINCT A.id, B.id FROM student A, supervisor B WHERE A.name='Fernandito' and B.name='Fernando';
INSERT INTO `stu_sup`(id_stu,id_sup) SELECT DISTINCT A.id, B.id FROM student A, supervisor B WHERE A.name='Fernandita' and B.name='Fernando';
INSERT INTO `stu_sup`(id_stu,id_sup) SELECT DISTINCT A.id, B.id FROM student A, supervisor B WHERE A.name='Arturito' and B.name='Fernando';
INSERT INTO `stu_sup`(id_stu,id_sup) SELECT DISTINCT A.id, B.id FROM student A, supervisor B WHERE A.name='Fernandito' and B.name='Don Fernando';
INSERT INTO `stu_sup`(id_stu,id_sup) SELECT DISTINCT A.id, B.id FROM student A, supervisor B WHERE A.name='Miguelín' and B.name='Miguel Ángel';
INSERT INTO `stu_sup`(id_stu,id_sup) SELECT DISTINCT A.id, B.id FROM student A, supervisor B WHERE A.name='Miguelita' and B.name='Miguel Ángel';
INSERT INTO `stu_sup`(id_stu,id_sup) SELECT DISTINCT A.id, B.id FROM student A, supervisor B WHERE A.name='Arturito' and B.name='Miguel Ángel';
INSERT INTO `stu_sup`(id_stu,id_sup) SELECT DISTINCT A.id, B.id FROM student A, supervisor B WHERE A.name='Miguelita' and B.name='Arturo';
INSERT INTO `stu_sup`(id_stu,id_sup) SELECT DISTINCT A.id, B.id FROM student A, supervisor B WHERE A.name='Miguelín' and B.name='Don Miguel';
INSERT INTO `stu_sup`(id_stu,id_sup) SELECT DISTINCT A.id, B.id FROM student A, supervisor B WHERE A.name='Arturito' and B.name='Arturo';
INSERT INTO `stu_sup`(id_stu,id_sup) SELECT DISTINCT A.id, B.id FROM student A, supervisor B WHERE A.name='Arturita' and B.name='Arturo';
INSERT INTO `stu_sup`(id_stu,id_sup) SELECT DISTINCT A.id, B.id FROM student A, supervisor B WHERE A.name='Arturito' and B.name='Don Arturo';
INSERT INTO `stu_sup`(id_stu,id_sup) SELECT DISTINCT A.id, B.id FROM student A, supervisor B WHERE A.name='Arturita' and B.name='Jesús';
INSERT INTO `stu_sup`(id_stu,id_sup) SELECT DISTINCT A.id, B.id FROM student A, supervisor B WHERE A.name='Jesusito' and B.name='Jesús';
INSERT INTO `stu_sup`(id_stu,id_sup) SELECT DISTINCT A.id, B.id FROM student A, supervisor B WHERE A.name='Jesusita' and B.name='Jesús';
INSERT INTO `stu_sup`(id_stu,id_sup) SELECT DISTINCT A.id, B.id FROM student A, supervisor B WHERE A.name='Jesusito' and B.name='Don Jesús';
INSERT INTO `stu_sup`(id_stu,id_sup) SELECT DISTINCT A.id, B.id FROM student A, supervisor B WHERE A.name='Alfonsito' and B.name='Alfonso';
INSERT INTO `stu_sup`(id_stu,id_sup) SELECT DISTINCT A.id, B.id FROM student A, supervisor B WHERE A.name='Alfonsita' and B.name='Alfonso';
INSERT INTO `stu_sup`(id_stu,id_sup) SELECT DISTINCT A.id, B.id FROM student A, supervisor B WHERE A.name='Jesusito' and B.name='Alfonso';
INSERT INTO `stu_sup`(id_stu,id_sup) SELECT DISTINCT A.id, B.id FROM student A, supervisor B WHERE A.name='Alfonsito' and B.name='Don Alfonso';
INSERT INTO `stu_sup`(id_stu,id_sup) SELECT DISTINCT A.id, B.id FROM student A, supervisor B WHERE A.name='Alfonsita' and B.name='Doña Alfonsa';
--
-- Student's CAJA offices
--
UPDATE student SET id_off=(SELECT id_off FROM supervisor WHERE supervisor.name='Fernando') WHERE student.name='Fernandito';
UPDATE student SET id_off=(SELECT id_off FROM supervisor WHERE supervisor.name='Miguel Ángel') WHERE student.name='Miguelín';
UPDATE student SET id_off=(SELECT id_off FROM supervisor WHERE supervisor.name='Arturo') WHERE student.name='Arturito';
UPDATE student SET id_off=(SELECT id_off FROM supervisor WHERE supervisor.name='Fernando') WHERE student.name='Fernandita';
UPDATE student SET id_off=(SELECT id_off FROM supervisor WHERE supervisor.name='Miguel Ángel') WHERE student.name='Miguelita';
UPDATE student SET id_off=(SELECT id_off FROM supervisor WHERE supervisor.name='Arturo') WHERE student.name='Arturita';
UPDATE student SET id_off=(SELECT id_off FROM supervisor WHERE supervisor.name='Alfonso') WHERE student.name='Alfonsito';
UPDATE student SET id_off=(SELECT id_off FROM supervisor WHERE supervisor.name='Alfonso') WHERE student.name='Alfonsita';
UPDATE student SET id_off=(SELECT id_off FROM supervisor WHERE supervisor.name='Jesús') WHERE student.name='Jesusito';
UPDATE student SET id_off=(SELECT id_off FROM supervisor WHERE supervisor.name='Jesús') WHERE student.name='Jesusita';
// select a.name,b.attributes,text from student a, stu_picto b, picto c, picto_exp d where a.id=b.id_stu and b.id_pic=c.id and c.id=d.id_pic and a.id=23 and a.lang=d.lang;
--
-- CAJA Core vocabulary
--
--
-- INSERT INTO stu_picto(id_stu,id_pic,scene,attributes)
-- SELECT S.id,P.id_pic, concat('{"id_cat":', if (id_cat_pic is null, 'null',id_cat_pic),
-- ',"coord_x":',coord_x,
-- ',"coord_y":',coord_y,
-- ',"status":"invisible"',
-- ',"highlight":false',
-- ',"color":', if (color is null, 'null',concat('"',color,'"')),
-- '}') as attributes
-- FROM student S, picto_core P
-- WHERE S.id_off =(SELECT id from office where name='Comunicación Aumentativa JAén (CAJA)');
--
-- Test method
--
-- INSERT INTO meta_method(name) VALUES (
-- 'Test MetaMethod'
-- );
-- INSERT INTO method(name, id_stu) VALUES (
-- 'Test Method',
-- (SELECT id FROM student WHERE username='aaa0002')
-- );
-- INSERT INTO instruction(name, id_met) VALUES (
-- 'Test Instruction',
-- (SELECT id FROM method WHERE name='Test Method')
-- );
-- INSERT INTO working_session (id_sup, id_ins) VALUES (
-- (SELECT id FROM supervisor WHERE email='dofer@ujaen.es'),
-- (SELECT id FROM instruction WHERE name='Test Instruction')
-- );
SET @TRIGGER_CHECKS = TRUE;
SET foreign_key_checks=1;
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');
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);
/*!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 */;
UNLOCK TABLES;
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);
/*!40000 ALTER TABLE `student` ENABLE KEYS */;
UNLOCK TABLES;
SET foreign_key_checks = 0;
ALTER TABLE supervisor ADD role enum('tutor','therapist','office','admin') NOT NULL;
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;
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 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 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);
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 (id_stu, id_off)
SELECT id, id_off
FROM student;
INSERT INTO sup_off (id_sup, id_off)
SELECT id, id_off
FROM 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;
DROP TABLE office;
# Changes
Nothing to do
#Database changes
## Database
SET foreign_key_checks = 0;
Nothing to do
#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;
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