554 lines
26 KiB
SQL
554 lines
26 KiB
SQL
CREATE DATABASE IF NOT EXISTS `proyecto_final` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci */ /*!80016 DEFAULT ENCRYPTION='N' */;
|
||
USE `proyecto_final`;
|
||
-- MySQL dump 10.13 Distrib 8.0.38, for Win64 (x86_64)
|
||
--
|
||
-- Host: localhost Database: proyecto_final
|
||
-- ------------------------------------------------------
|
||
-- Server version 8.0.33
|
||
|
||
/*!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 */;
|
||
/*!50503 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 `actividades`
|
||
--
|
||
|
||
DROP TABLE IF EXISTS `actividades`;
|
||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||
/*!50503 SET character_set_client = utf8mb4 */;
|
||
CREATE TABLE `actividades` (
|
||
`id_actividad` int NOT NULL AUTO_INCREMENT,
|
||
`id_categoria` int NOT NULL,
|
||
`nombre` varchar(100) NOT NULL,
|
||
`descripcion` text,
|
||
`duracion_minutos` int NOT NULL,
|
||
`dificultad` tinyint NOT NULL DEFAULT '1',
|
||
`puntos_base` int NOT NULL DEFAULT '10',
|
||
`activo` tinyint(1) NOT NULL DEFAULT '1',
|
||
PRIMARY KEY (`id_actividad`),
|
||
KEY `id_categoria` (`id_categoria`),
|
||
CONSTRAINT `actividades_ibfk_1` FOREIGN KEY (`id_categoria`) REFERENCES `categorias` (`id_categoria`)
|
||
) ENGINE=InnoDB AUTO_INCREMENT=34 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||
|
||
--
|
||
-- Dumping data for table `actividades`
|
||
--
|
||
|
||
LOCK TABLES `actividades` WRITE;
|
||
/*!40000 ALTER TABLE `actividades` DISABLE KEYS */;
|
||
INSERT INTO `actividades` VALUES (1,1,'Estiramiento de cuello','Movimientos suaves de cuello, 5 repeticiones por lado',3,1,10,1),(2,1,'Bailar tu canción','Baila una canción completa para activar el ánimo',4,1,14,1),(3,1,'Caminata corta','Caminar a ritmo cómodo cerca de tu casa o patio',5,1,12,1),(4,1,'Saltos suaves','10–20 saltos de tijera a tu ritmo',5,2,14,1),(5,1,'Sentadillas guiadas','2 series de 10 sentadillas',5,2,16,1),(6,1,'Movilidad de hombros','Círculos de hombros y apertura torácica',4,1,12,1),(7,1,'Subir/bajar gradas','Sube y baja escalones con cuidado',5,3,18,1),(8,1,'Trote ligero','Trote suave en el lugar o patio',6,3,20,1),(9,2,'Saludar a un compañero','Envía un mensaje amable a un compañero y manten la conversacion por 10 minutos',3,1,10,1),(10,2,'Agradecimiento','Comparte un “gracias” genuino con alguien cercano',3,1,10,1),(11,2,'Charla breve en familia','Habla 5 min con un familiar sobre su día',5,1,12,1),(12,2,'Ayuda rápida','Ofrece ayuda con una tarea simple a alguien',4,2,14,1),(13,2,'Mensaje positivo','Comparte una frase motivadora con un amigo',3,1,10,1),(14,2,'Escucha activa','Escucha sin interrumpir durante 3–5 min',5,2,16,1),(15,2,'Felicitación','Reconoce un logro de alguien de tu clase',3,1,12,1),(16,2,'Círculo de gratitud','Comparte 3 cosas por las que estás agradecido',5,2,16,1),(17,3,'Respiración 4-4-4','Inhala 4s, mantén 4s, exhala 4s',3,1,12,1),(18,3,'Pausa consciente','Deja el celular y respira 3 min',3,1,12,1),(19,3,'Escaneo corporal','Revisa tensiones de pies a cabeza',5,2,14,1),(20,3,'Diario emocional','Escribe en una hoja de papel cómo te sientes hoy',5,1,12,1),(21,3,'Cuenta 5-4-3-2-1','Técnica sensorial para anclaje al presente',4,2,14,1),(22,3,'Visualización meta','Imagina cumplir una meta pequeña de hoy',4,1,12,1),(23,3,'Afirmaciones','Repite 5 afirmaciones positivas',3,1,10,1),(24,3,'Técnica pomodoro suave','1 bloque corto de foco + mini pausa consciente',8,3,20,1),(25,4,'Lectura 3 min','Lee un texto breve y subraya 1 idea clave',3,1,12,1),(26,4,'Colorear','Colorea un dibujo',5,2,16,1),(27,4,'Resumen flash','Escribe 3–4 líneas de lo aprendido',5,2,16,1),(28,4,'Vídeo educativo corto','Mira un video y anota 2 ideas clave',6,2,16,1),(29,4,'Preguntas guía','Escribe 3 preguntas sobre el tema',4,1,12,1),(30,4,'Repaso activo','Explica en voz alta el tema a alguien',6,3,20,1),(31,4,'Resuelve un acertijo','Resuleve un acertijo sencillo ',5,2,16,1),(32,4,'Lectura 10 min','Profundiza y extrae 3 conceptos clave',10,3,22,1),(33,1,'Caminata corta','Caminar 12 min a ritmo cómodo',12,1,14,1);
|
||
/*!40000 ALTER TABLE `actividades` ENABLE KEYS */;
|
||
UNLOCK TABLES;
|
||
|
||
--
|
||
-- Table structure for table `agenda_actividades`
|
||
--
|
||
|
||
DROP TABLE IF EXISTS `agenda_actividades`;
|
||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||
/*!50503 SET character_set_client = utf8mb4 */;
|
||
CREATE TABLE `agenda_actividades` (
|
||
`id_agenda` int NOT NULL AUTO_INCREMENT,
|
||
`id_usuario` int NOT NULL,
|
||
`id_actividad` int NOT NULL,
|
||
`fecha_programada` datetime NOT NULL,
|
||
`estado` enum('pendiente','realizada','omitida','reprogramada') NOT NULL DEFAULT 'pendiente',
|
||
PRIMARY KEY (`id_agenda`),
|
||
KEY `id_actividad` (`id_actividad`),
|
||
KEY `idx_usuario_programa` (`id_usuario`,`fecha_programada`),
|
||
CONSTRAINT `agenda_actividades_ibfk_1` FOREIGN KEY (`id_usuario`) REFERENCES `usuarios` (`id_usuario`),
|
||
CONSTRAINT `agenda_actividades_ibfk_2` FOREIGN KEY (`id_actividad`) REFERENCES `actividades` (`id_actividad`)
|
||
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||
|
||
--
|
||
-- Dumping data for table `agenda_actividades`
|
||
--
|
||
|
||
LOCK TABLES `agenda_actividades` WRITE;
|
||
/*!40000 ALTER TABLE `agenda_actividades` DISABLE KEYS */;
|
||
INSERT INTO `agenda_actividades` VALUES (1,1,1,'2025-09-22 10:30:00','realizada');
|
||
/*!40000 ALTER TABLE `agenda_actividades` ENABLE KEYS */;
|
||
UNLOCK TABLES;
|
||
|
||
--
|
||
-- Table structure for table `categorias`
|
||
--
|
||
|
||
DROP TABLE IF EXISTS `categorias`;
|
||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||
/*!50503 SET character_set_client = utf8mb4 */;
|
||
CREATE TABLE `categorias` (
|
||
`id_categoria` int NOT NULL AUTO_INCREMENT,
|
||
`nombre` varchar(50) NOT NULL,
|
||
`descripcion` text,
|
||
`activo` tinyint(1) NOT NULL DEFAULT '1',
|
||
PRIMARY KEY (`id_categoria`)
|
||
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||
|
||
--
|
||
-- Dumping data for table `categorias`
|
||
--
|
||
|
||
LOCK TABLES `categorias` WRITE;
|
||
/*!40000 ALTER TABLE `categorias` DISABLE KEYS */;
|
||
INSERT INTO `categorias` VALUES (1,'Fisica','Movimientos y ejercicios cortos para activar el cuerpo',1),(2,'Sociales','Acciones breves para socializar y mejorar vínculos',1),(3,'Mentales','Respiración, mindfulness, escritura, gestión emocional',1),(4,'Creativas','Actividades que activen la creatividad, dibujo, pintura',1),(5,'prueba cambio','actividad prueba cambio',0),(6,'Diversion','esto es una prueba de creacion de categorias',1);
|
||
/*!40000 ALTER TABLE `categorias` ENABLE KEYS */;
|
||
UNLOCK TABLES;
|
||
|
||
--
|
||
-- Table structure for table `dispositivos_push`
|
||
--
|
||
|
||
DROP TABLE IF EXISTS `dispositivos_push`;
|
||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||
/*!50503 SET character_set_client = utf8mb4 */;
|
||
CREATE TABLE `dispositivos_push` (
|
||
`id_dispositivo` int NOT NULL AUTO_INCREMENT,
|
||
`id_usuario` int NOT NULL,
|
||
`proveedor` enum('FCM','APNS','WEBPUSH') NOT NULL DEFAULT 'FCM',
|
||
`device_token` varchar(512) NOT NULL,
|
||
`plataforma` enum('android','ios','web') NOT NULL,
|
||
`activo` tinyint(1) NOT NULL DEFAULT '1',
|
||
`fecha_registro` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||
PRIMARY KEY (`id_dispositivo`),
|
||
UNIQUE KEY `uq_usuario_token` (`id_usuario`,`device_token`),
|
||
CONSTRAINT `dispositivos_push_ibfk_1` FOREIGN KEY (`id_usuario`) REFERENCES `usuarios` (`id_usuario`)
|
||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||
|
||
--
|
||
-- Dumping data for table `dispositivos_push`
|
||
--
|
||
|
||
LOCK TABLES `dispositivos_push` WRITE;
|
||
/*!40000 ALTER TABLE `dispositivos_push` DISABLE KEYS */;
|
||
/*!40000 ALTER TABLE `dispositivos_push` ENABLE KEYS */;
|
||
UNLOCK TABLES;
|
||
|
||
--
|
||
-- Table structure for table `insignias`
|
||
--
|
||
|
||
DROP TABLE IF EXISTS `insignias`;
|
||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||
/*!50503 SET character_set_client = utf8mb4 */;
|
||
CREATE TABLE `insignias` (
|
||
`id_insignia` int NOT NULL AUTO_INCREMENT,
|
||
`nombre` varchar(60) NOT NULL,
|
||
`descripcion` text,
|
||
`criterio_tipo` enum('actividades_completadas','streak_dias','minutos_acumulados','categoria_completada','puntos_acumulados') NOT NULL,
|
||
`criterio_valor` int NOT NULL,
|
||
`icono` varchar(200) DEFAULT NULL,
|
||
PRIMARY KEY (`id_insignia`)
|
||
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||
|
||
--
|
||
-- Dumping data for table `insignias`
|
||
--
|
||
|
||
LOCK TABLES `insignias` WRITE;
|
||
/*!40000 ALTER TABLE `insignias` DISABLE KEYS */;
|
||
INSERT INTO `insignias` VALUES (1,'¡Primera misión! :)','Completa tu primera actividad','actividades_completadas',1,NULL),(2,'En racha 3','Mantén 3 días seguidos de actividad','streak_dias',3,NULL),(3,'100 minutos','Acumula 100 minutos de actividades','minutos_acumulados',100,NULL),(4,'Cien puntos','Acumula 100 puntos totales','puntos_acumulados',100,NULL),(5,'Constante 7','Mantén 7 días de racha','streak_dias',7,NULL);
|
||
/*!40000 ALTER TABLE `insignias` ENABLE KEYS */;
|
||
UNLOCK TABLES;
|
||
|
||
--
|
||
-- Table structure for table `metas`
|
||
--
|
||
|
||
DROP TABLE IF EXISTS `metas`;
|
||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||
/*!50503 SET character_set_client = utf8mb4 */;
|
||
CREATE TABLE `metas` (
|
||
`id_meta` int NOT NULL AUTO_INCREMENT,
|
||
`id_usuario` int NOT NULL,
|
||
`tipo` enum('minutos','actividades','puntos','categoria') NOT NULL,
|
||
`valor_objetivo` int NOT NULL,
|
||
`id_categoria` int DEFAULT NULL,
|
||
`fecha_inicio` date NOT NULL,
|
||
`fecha_fin` date NOT NULL,
|
||
`estado` enum('activa','cumplida','vencida') NOT NULL DEFAULT 'activa',
|
||
`progreso_actual` int NOT NULL DEFAULT '0',
|
||
`creada_en` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||
PRIMARY KEY (`id_meta`),
|
||
KEY `id_usuario` (`id_usuario`),
|
||
KEY `id_categoria` (`id_categoria`),
|
||
CONSTRAINT `metas_ibfk_1` FOREIGN KEY (`id_usuario`) REFERENCES `usuarios` (`id_usuario`),
|
||
CONSTRAINT `metas_ibfk_2` FOREIGN KEY (`id_categoria`) REFERENCES `categorias` (`id_categoria`)
|
||
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||
|
||
--
|
||
-- Dumping data for table `metas`
|
||
--
|
||
|
||
LOCK TABLES `metas` WRITE;
|
||
/*!40000 ALTER TABLE `metas` DISABLE KEYS */;
|
||
INSERT INTO `metas` VALUES (2,1,'minutos',100,1,'2025-09-19','2025-09-26','activa',40,'2025-09-19 00:43:44');
|
||
/*!40000 ALTER TABLE `metas` ENABLE KEYS */;
|
||
UNLOCK TABLES;
|
||
|
||
--
|
||
-- Table structure for table `niveles`
|
||
--
|
||
|
||
DROP TABLE IF EXISTS `niveles`;
|
||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||
/*!50503 SET character_set_client = utf8mb4 */;
|
||
CREATE TABLE `niveles` (
|
||
`id_nivel` int NOT NULL AUTO_INCREMENT,
|
||
`nombre` varchar(50) NOT NULL,
|
||
`puntos_minimos` int NOT NULL,
|
||
`puntos_maximos` int NOT NULL,
|
||
PRIMARY KEY (`id_nivel`)
|
||
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||
|
||
--
|
||
-- Dumping data for table `niveles`
|
||
--
|
||
|
||
LOCK TABLES `niveles` WRITE;
|
||
/*!40000 ALTER TABLE `niveles` DISABLE KEYS */;
|
||
INSERT INTO `niveles` VALUES (1,'Explorador',0,99),(2,'Aprendiz',100,249),(3,'Avanzado',250,499),(4,'Experto :)',500,999);
|
||
/*!40000 ALTER TABLE `niveles` ENABLE KEYS */;
|
||
UNLOCK TABLES;
|
||
|
||
--
|
||
-- Table structure for table `notificaciones`
|
||
--
|
||
|
||
DROP TABLE IF EXISTS `notificaciones`;
|
||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||
/*!50503 SET character_set_client = utf8mb4 */;
|
||
CREATE TABLE `notificaciones` (
|
||
`id_notificacion` int NOT NULL AUTO_INCREMENT,
|
||
`id_usuario` int NOT NULL,
|
||
`tipo` enum('recordatorio','motivacion','sistema') NOT NULL DEFAULT 'recordatorio',
|
||
`titulo` varchar(120) NOT NULL,
|
||
`cuerpo` varchar(500) NOT NULL,
|
||
`canal` enum('push','email','sms') NOT NULL DEFAULT 'push',
|
||
`programada_para` datetime DEFAULT NULL,
|
||
`enviada_en` datetime DEFAULT NULL,
|
||
`leida_en` datetime DEFAULT NULL,
|
||
`estado` enum('pendiente','enviada','fallida','cancelada') NOT NULL DEFAULT 'pendiente',
|
||
`meta` json DEFAULT NULL,
|
||
`creada_en` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||
PRIMARY KEY (`id_notificacion`),
|
||
KEY `idx_notif_usuario_estado` (`id_usuario`,`estado`),
|
||
CONSTRAINT `notificaciones_ibfk_1` FOREIGN KEY (`id_usuario`) REFERENCES `usuarios` (`id_usuario`)
|
||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||
|
||
--
|
||
-- Dumping data for table `notificaciones`
|
||
--
|
||
|
||
LOCK TABLES `notificaciones` WRITE;
|
||
/*!40000 ALTER TABLE `notificaciones` DISABLE KEYS */;
|
||
/*!40000 ALTER TABLE `notificaciones` ENABLE KEYS */;
|
||
UNLOCK TABLES;
|
||
|
||
--
|
||
-- Table structure for table `registro_actividad`
|
||
--
|
||
|
||
DROP TABLE IF EXISTS `registro_actividad`;
|
||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||
/*!50503 SET character_set_client = utf8mb4 */;
|
||
CREATE TABLE `registro_actividad` (
|
||
`id_registro` int NOT NULL AUTO_INCREMENT,
|
||
`id_usuario` int NOT NULL,
|
||
`id_actividad` int NOT NULL,
|
||
`fecha_inicio` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||
`fecha_fin` datetime DEFAULT NULL,
|
||
`emocion` enum('feliz','neutral','triste','ansioso','motivado','cansado') DEFAULT NULL,
|
||
`completada` tinyint(1) NOT NULL DEFAULT '0',
|
||
`puntos_obtenidos` int NOT NULL DEFAULT '0',
|
||
`comentario` text,
|
||
PRIMARY KEY (`id_registro`),
|
||
KEY `id_actividad` (`id_actividad`),
|
||
KEY `idx_usuario_fecha` (`id_usuario`,`fecha_inicio`),
|
||
CONSTRAINT `registro_actividad_ibfk_1` FOREIGN KEY (`id_usuario`) REFERENCES `usuarios` (`id_usuario`),
|
||
CONSTRAINT `registro_actividad_ibfk_2` FOREIGN KEY (`id_actividad`) REFERENCES `actividades` (`id_actividad`)
|
||
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||
|
||
--
|
||
-- Dumping data for table `registro_actividad`
|
||
--
|
||
|
||
LOCK TABLES `registro_actividad` WRITE;
|
||
/*!40000 ALTER TABLE `registro_actividad` DISABLE KEYS */;
|
||
INSERT INTO `registro_actividad` VALUES (1,1,1,'2025-09-22 02:00:33',NULL,NULL,0,0,NULL),(2,1,1,'2025-09-22 02:03:11','2025-09-22 02:05:29','motivado',1,15,'todo ok'),(3,1,5,'2025-09-22 23:51:17','2025-09-22 23:53:36','feliz',1,20,'¡listo!'),(4,3,24,'2025-10-14 00:38:37',NULL,NULL,0,0,NULL),(5,2,33,'2025-10-14 01:00:07','2025-10-14 01:00:10',NULL,1,14,NULL),(6,2,32,'2025-10-14 13:07:17',NULL,NULL,0,0,NULL),(7,2,23,'2025-10-14 13:16:32','2025-10-14 13:17:15',NULL,1,10,NULL),(8,3,24,'2025-10-14 13:29:53','2025-10-14 13:30:40',NULL,1,20,NULL);
|
||
/*!40000 ALTER TABLE `registro_actividad` ENABLE KEYS */;
|
||
UNLOCK TABLES;
|
||
|
||
--
|
||
-- Table structure for table `roles`
|
||
--
|
||
|
||
DROP TABLE IF EXISTS `roles`;
|
||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||
/*!50503 SET character_set_client = utf8mb4 */;
|
||
CREATE TABLE `roles` (
|
||
`id_rol` int NOT NULL AUTO_INCREMENT,
|
||
`nombre` varchar(50) NOT NULL,
|
||
`descripcion` text,
|
||
PRIMARY KEY (`id_rol`),
|
||
UNIQUE KEY `nombre` (`nombre`)
|
||
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||
|
||
--
|
||
-- Dumping data for table `roles`
|
||
--
|
||
|
||
LOCK TABLES `roles` WRITE;
|
||
/*!40000 ALTER TABLE `roles` DISABLE KEYS */;
|
||
INSERT INTO `roles` VALUES (1,'admin','Administrador del sistema'),(3,'alumno','Usuario estudiante'),(4,'pueba rol','acttualizacion de datos desde postman');
|
||
/*!40000 ALTER TABLE `roles` ENABLE KEYS */;
|
||
UNLOCK TABLES;
|
||
|
||
--
|
||
-- Table structure for table `users`
|
||
--
|
||
|
||
DROP TABLE IF EXISTS `users`;
|
||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||
/*!50503 SET character_set_client = utf8mb4 */;
|
||
CREATE TABLE `users` (
|
||
`user_id` int NOT NULL AUTO_INCREMENT,
|
||
`name` varchar(100) NOT NULL,
|
||
`email` varchar(100) NOT NULL,
|
||
`password` varchar(255) NOT NULL,
|
||
`role` enum('student','admin') DEFAULT 'student',
|
||
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
|
||
PRIMARY KEY (`user_id`),
|
||
UNIQUE KEY `email` (`email`)
|
||
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||
|
||
--
|
||
-- Dumping data for table `users`
|
||
--
|
||
|
||
LOCK TABLES `users` WRITE;
|
||
/*!40000 ALTER TABLE `users` DISABLE KEYS */;
|
||
INSERT INTO `users` VALUES (1,'Aline','aline@test.com','$2b$10$vVx3nhzjI77x08MQoigNruwLS.oYpfGkOGLZSkX3BcU2sbVzhHVIu','student','2025-09-05 07:27:38');
|
||
/*!40000 ALTER TABLE `users` ENABLE KEYS */;
|
||
UNLOCK TABLES;
|
||
|
||
--
|
||
-- Table structure for table `usuario_actividad_estado`
|
||
--
|
||
|
||
DROP TABLE IF EXISTS `usuario_actividad_estado`;
|
||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||
/*!50503 SET character_set_client = utf8mb4 */;
|
||
CREATE TABLE `usuario_actividad_estado` (
|
||
`id_usuario` int NOT NULL,
|
||
`id_actividad` int NOT NULL,
|
||
`estado` enum('pendiente','realizada') NOT NULL DEFAULT 'pendiente',
|
||
`fecha_realizada` datetime DEFAULT NULL,
|
||
PRIMARY KEY (`id_usuario`,`id_actividad`),
|
||
KEY `fk_uas_actividad` (`id_actividad`),
|
||
CONSTRAINT `fk_uas_actividad` FOREIGN KEY (`id_actividad`) REFERENCES `actividades` (`id_actividad`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||
CONSTRAINT `fk_uas_usuario` FOREIGN KEY (`id_usuario`) REFERENCES `usuarios` (`id_usuario`) ON DELETE CASCADE ON UPDATE CASCADE
|
||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||
|
||
--
|
||
-- Dumping data for table `usuario_actividad_estado`
|
||
--
|
||
|
||
LOCK TABLES `usuario_actividad_estado` WRITE;
|
||
/*!40000 ALTER TABLE `usuario_actividad_estado` DISABLE KEYS */;
|
||
INSERT INTO `usuario_actividad_estado` VALUES (2,23,'realizada','2025-10-14 13:17:15'),(3,24,'realizada','2025-10-14 13:30:40');
|
||
/*!40000 ALTER TABLE `usuario_actividad_estado` ENABLE KEYS */;
|
||
UNLOCK TABLES;
|
||
|
||
--
|
||
-- Table structure for table `usuario_metricas`
|
||
--
|
||
|
||
DROP TABLE IF EXISTS `usuario_metricas`;
|
||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||
/*!50503 SET character_set_client = utf8mb4 */;
|
||
CREATE TABLE `usuario_metricas` (
|
||
`id_metricas` int NOT NULL AUTO_INCREMENT,
|
||
`id_usuario` int NOT NULL,
|
||
`actividades_completadas` int NOT NULL DEFAULT '0',
|
||
`tiempo_total_minutos` int NOT NULL DEFAULT '0',
|
||
`puntos_totales` int NOT NULL DEFAULT '0',
|
||
`racha_dias` int NOT NULL DEFAULT '0',
|
||
`nivel_actual` int DEFAULT NULL,
|
||
`porcentaje_avance` decimal(5,2) NOT NULL DEFAULT '0.00',
|
||
`actualizado_en` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||
PRIMARY KEY (`id_metricas`),
|
||
UNIQUE KEY `uq_usuario_metricas` (`id_usuario`),
|
||
CONSTRAINT `fk_usuario_metricas_usuario` FOREIGN KEY (`id_usuario`) REFERENCES `usuarios` (`id_usuario`) ON DELETE CASCADE ON UPDATE CASCADE
|
||
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||
|
||
--
|
||
-- Dumping data for table `usuario_metricas`
|
||
--
|
||
|
||
LOCK TABLES `usuario_metricas` WRITE;
|
||
/*!40000 ALTER TABLE `usuario_metricas` DISABLE KEYS */;
|
||
INSERT INTO `usuario_metricas` VALUES (1,1,1,12,140,0,2,26.67,'2025-10-17 23:59:00'),(2,2,2,0,24,0,1,0.00,'2025-10-17 23:59:00'),(8,3,1,0,20,0,1,0.00,'2025-10-17 23:59:00');
|
||
/*!40000 ALTER TABLE `usuario_metricas` ENABLE KEYS */;
|
||
UNLOCK TABLES;
|
||
|
||
--
|
||
-- Table structure for table `usuarios`
|
||
--
|
||
|
||
DROP TABLE IF EXISTS `usuarios`;
|
||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||
/*!50503 SET character_set_client = utf8mb4 */;
|
||
CREATE TABLE `usuarios` (
|
||
`id_usuario` int NOT NULL AUTO_INCREMENT,
|
||
`nombre` varchar(100) NOT NULL,
|
||
`apellido` varchar(100) NOT NULL,
|
||
`email` varchar(100) NOT NULL,
|
||
`password_hash` varchar(255) NOT NULL,
|
||
`fecha_registro` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||
`fecha_nacimiento` date DEFAULT NULL,
|
||
`genero` enum('F','M','O') DEFAULT NULL,
|
||
`activo` tinyint(1) NOT NULL DEFAULT '1',
|
||
PRIMARY KEY (`id_usuario`),
|
||
UNIQUE KEY `email` (`email`)
|
||
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||
|
||
--
|
||
-- Dumping data for table `usuarios`
|
||
--
|
||
|
||
LOCK TABLES `usuarios` WRITE;
|
||
/*!40000 ALTER TABLE `usuarios` DISABLE KEYS */;
|
||
INSERT INTO `usuarios` VALUES (1,'Raquel','Garcia','agarciap31@miumg.edu.gt','12705beecd4f6c9778b8c49468a56b60008ce4413d96319a2024d76c72cbd634','2025-08-25 23:42:31','2000-01-01','F',1),(2,'lorena','perez','loren@ie.gt','$2b$10$MBUclniGWZncL8NEUNrLXuNfgLCOIu9Jz3bNu2b3deYjPp4y1fJNq','2025-09-05 23:15:29',NULL,'F',1),(3,'maria','hernandez','mhernandez@gmail.com','$2b$10$OwQOfA7/6DV6CvTbyohKUe9CtfGXZsnXlVP3Y9M2y8yPIHoQiVgG2','2025-10-12 23:51:13',NULL,'F',1),(4,'admin','general','admin@ie.gt','$2b$10$98wqTieEOCMd.Iw331AhGulmdYFn.7LxaQGKG3O.qwzs12MLsuKyK','2025-10-14 23:33:21',NULL,'F',1),(5,'mishel','admin','mishel@ie.gt','$2b$10$15InnRXqniiklsRJj8k06O1vP8QGtagtk9Pv54gGXifLhQVqzHY7O','2025-10-14 23:56:54',NULL,'F',1);
|
||
/*!40000 ALTER TABLE `usuarios` ENABLE KEYS */;
|
||
UNLOCK TABLES;
|
||
|
||
--
|
||
-- Table structure for table `usuarios_insignias`
|
||
--
|
||
|
||
DROP TABLE IF EXISTS `usuarios_insignias`;
|
||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||
/*!50503 SET character_set_client = utf8mb4 */;
|
||
CREATE TABLE `usuarios_insignias` (
|
||
`id_usuario` int NOT NULL,
|
||
`id_insignia` int NOT NULL,
|
||
`fecha_otorgada` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||
PRIMARY KEY (`id_usuario`,`id_insignia`),
|
||
UNIQUE KEY `uq_usuario_insignia` (`id_usuario`,`id_insignia`),
|
||
KEY `id_insignia` (`id_insignia`),
|
||
CONSTRAINT `usuarios_insignias_ibfk_1` FOREIGN KEY (`id_usuario`) REFERENCES `usuarios` (`id_usuario`),
|
||
CONSTRAINT `usuarios_insignias_ibfk_2` FOREIGN KEY (`id_insignia`) REFERENCES `insignias` (`id_insignia`)
|
||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||
|
||
--
|
||
-- Dumping data for table `usuarios_insignias`
|
||
--
|
||
|
||
LOCK TABLES `usuarios_insignias` WRITE;
|
||
/*!40000 ALTER TABLE `usuarios_insignias` DISABLE KEYS */;
|
||
INSERT INTO `usuarios_insignias` VALUES (1,1,'2025-09-22 02:05:29'),(1,3,'2025-09-25 01:15:20'),(2,1,'2025-10-14 01:00:10'),(3,1,'2025-10-14 13:30:40');
|
||
/*!40000 ALTER TABLE `usuarios_insignias` ENABLE KEYS */;
|
||
UNLOCK TABLES;
|
||
|
||
--
|
||
-- Table structure for table `usuarios_roles`
|
||
--
|
||
|
||
DROP TABLE IF EXISTS `usuarios_roles`;
|
||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||
/*!50503 SET character_set_client = utf8mb4 */;
|
||
CREATE TABLE `usuarios_roles` (
|
||
`id_usuario` int NOT NULL,
|
||
`id_rol` int NOT NULL,
|
||
PRIMARY KEY (`id_usuario`,`id_rol`),
|
||
UNIQUE KEY `uq_usuario_rol` (`id_usuario`,`id_rol`),
|
||
KEY `fk_ur_rol` (`id_rol`),
|
||
CONSTRAINT `fk_ur_rol` FOREIGN KEY (`id_rol`) REFERENCES `roles` (`id_rol`) ON DELETE RESTRICT ON UPDATE CASCADE,
|
||
CONSTRAINT `fk_ur_usuario` FOREIGN KEY (`id_usuario`) REFERENCES `usuarios` (`id_usuario`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||
CONSTRAINT `usuarios_roles_ibfk_1` FOREIGN KEY (`id_usuario`) REFERENCES `usuarios` (`id_usuario`),
|
||
CONSTRAINT `usuarios_roles_ibfk_2` FOREIGN KEY (`id_rol`) REFERENCES `roles` (`id_rol`)
|
||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||
|
||
--
|
||
-- Dumping data for table `usuarios_roles`
|
||
--
|
||
|
||
LOCK TABLES `usuarios_roles` WRITE;
|
||
/*!40000 ALTER TABLE `usuarios_roles` DISABLE KEYS */;
|
||
INSERT INTO `usuarios_roles` VALUES (1,1),(4,1);
|
||
/*!40000 ALTER TABLE `usuarios_roles` ENABLE KEYS */;
|
||
UNLOCK TABLES;
|
||
|
||
--
|
||
-- Temporary view structure for view `v_usuario_progreso`
|
||
--
|
||
|
||
DROP TABLE IF EXISTS `v_usuario_progreso`;
|
||
/*!50001 DROP VIEW IF EXISTS `v_usuario_progreso`*/;
|
||
SET @saved_cs_client = @@character_set_client;
|
||
/*!50503 SET character_set_client = utf8mb4 */;
|
||
/*!50001 CREATE VIEW `v_usuario_progreso` AS SELECT
|
||
1 AS `id_usuario`,
|
||
1 AS `usuario`,
|
||
1 AS `actividades_completadas`,
|
||
1 AS `tiempo_total_minutos`,
|
||
1 AS `puntos_totales`,
|
||
1 AS `racha_dias`,
|
||
1 AS `id_nivel`,
|
||
1 AS `nivel`*/;
|
||
SET character_set_client = @saved_cs_client;
|
||
|
||
--
|
||
-- Final view structure for view `v_usuario_progreso`
|
||
--
|
||
|
||
/*!50001 DROP VIEW IF EXISTS `v_usuario_progreso`*/;
|
||
/*!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 = utf8mb4 */;
|
||
/*!50001 SET character_set_results = utf8mb4 */;
|
||
/*!50001 SET collation_connection = utf8mb4_0900_ai_ci */;
|
||
/*!50001 CREATE ALGORITHM=UNDEFINED */
|
||
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
|
||
/*!50001 VIEW `v_usuario_progreso` AS select `u`.`id_usuario` AS `id_usuario`,concat(`u`.`nombre`,' ',`u`.`apellido`) AS `usuario`,ifnull(`um`.`actividades_completadas`,0) AS `actividades_completadas`,ifnull(`um`.`tiempo_total_minutos`,0) AS `tiempo_total_minutos`,ifnull(`um`.`puntos_totales`,0) AS `puntos_totales`,ifnull(`um`.`racha_dias`,0) AS `racha_dias`,`n`.`id_nivel` AS `id_nivel`,`n`.`nombre` AS `nivel` from ((`usuarios` `u` left join `usuario_metricas` `um` on((`um`.`id_usuario` = `u`.`id_usuario`))) left join `niveles` `n` on((`um`.`puntos_totales` between `n`.`puntos_minimos` and `n`.`puntos_maximos`))) */;
|
||
/*!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 2025-10-18 20:01:07
|