Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
6 views4 pages

Create Database If Not Exists 'Asi

Uploaded by

monsunodaniel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views4 pages

Create Database If Not Exists 'Asi

Uploaded by

monsunodaniel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

CREATE DATABASE IF NOT EXISTS `asistencia` /*!

40100 DEFAULT CHARACTER SET utf8mb4


COLLATE utf8mb4_0900_ai_ci */ /*!80016 DEFAULT ENCRYPTION='N' */;
USE `asistencia`;
-- MySQL dump 10.13 Distrib 8.0.41, for Win64 (x86_64)
--
-- Host: localhost Database: asistencia
-- ------------------------------------------------------
-- Server version 8.0.41

/*!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 `alumnos`
--

DROP TABLE IF EXISTS `alumnos`;


/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `alumnos` (
`id_alumno` int NOT NULL AUTO_INCREMENT,
`nombre` varchar(100) NOT NULL,
`apellidos` varchar(100) NOT NULL,
`correo` varchar(150) NOT NULL,
`password_hash` varchar(255) NOT NULL,
`fecha_registro` datetime DEFAULT CURRENT_TIMESTAMP,
`id_curso` int DEFAULT NULL,
PRIMARY KEY (`id_alumno`),
UNIQUE KEY `correo` (`correo`),
KEY `id_curso` (`id_curso`),
CONSTRAINT `fk_alumno_curso` FOREIGN KEY (`id_curso`) REFERENCES `cursos`
(`id_curso`) ON DELETE RESTRICT ON UPDATE CASCADE
) 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 `alumnos`
--

LOCK TABLES `alumnos` WRITE;


/*!40000 ALTER TABLE `alumnos` DISABLE KEYS */;
INSERT INTO `alumnos` VALUES
(1,'Lucas','Perez','[email protected]','lucas1','2025-05-21 00:00:00',201),
(2,'Pedro','Pica','[email protected]','pedro1','2025-04-23 00:00:00',202);
/*!40000 ALTER TABLE `alumnos` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `asignaturas`
--
DROP TABLE IF EXISTS `asignaturas`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `asignaturas` (
`id_asignatura` int NOT NULL AUTO_INCREMENT,
`nombre` varchar(100) NOT NULL,
`descripcion` text,
PRIMARY KEY (`id_asignatura`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4
COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `asignaturas`
--

LOCK TABLES `asignaturas` WRITE;


/*!40000 ALTER TABLE `asignaturas` DISABLE KEYS */;
INSERT INTO `asignaturas` VALUES (1,'Programacion',NULL),(2,'Base de datos',NULL),
(3,'Matematicas',NULL);
/*!40000 ALTER TABLE `asignaturas` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `cursos`
--

DROP TABLE IF EXISTS `cursos`;


/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `cursos` (
`id_curso` int NOT NULL AUTO_INCREMENT,
`nombre` varchar(50) NOT NULL,
`nivel` varchar(50) DEFAULT NULL,
`descripcion` text,
PRIMARY KEY (`id_curso`)
) ENGINE=InnoDB AUTO_INCREMENT=203 DEFAULT CHARSET=utf8mb4
COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `cursos`
--

LOCK TABLES `cursos` WRITE;


/*!40000 ALTER TABLE `cursos` DISABLE KEYS */;
INSERT INTO `cursos` VALUES (201,'DAM','Grado Superior',NULL),(202,'DAW','Grado
Superior',NULL);
/*!40000 ALTER TABLE `cursos` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `fichajes`
--

DROP TABLE IF EXISTS `fichajes`;


/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `fichajes` (
`id_fichaje` int NOT NULL AUTO_INCREMENT,
`id_alumno` int NOT NULL,
`id_horario` int NOT NULL,
`fecha` date NOT NULL,
`presente` tinyint(1) NOT NULL DEFAULT '1',
`timestamp_registro` datetime DEFAULT CURRENT_TIMESTAMP,
`observaciones` text,
PRIMARY KEY (`id_fichaje`),
KEY `id_alumno` (`id_alumno`),
KEY `id_horario` (`id_horario`),
CONSTRAINT `fk_fichaje_alumno` FOREIGN KEY (`id_alumno`) REFERENCES `alumnos`
(`id_alumno`) ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT `fk_fichaje_horario` FOREIGN KEY (`id_horario`) REFERENCES `horarios`
(`id_horario`) ON DELETE RESTRICT ON UPDATE CASCADE
) 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 `fichajes`
--

LOCK TABLES `fichajes` WRITE;


/*!40000 ALTER TABLE `fichajes` DISABLE KEYS */;
INSERT INTO `fichajes` VALUES (1,1,1,'2025-05-21',0,'2025-05-21 21:35:59',NULL);
/*!40000 ALTER TABLE `fichajes` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `horarios`
--

DROP TABLE IF EXISTS `horarios`;


/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `horarios` (
`id_horario` int NOT NULL AUTO_INCREMENT,
`id_asignatura` int NOT NULL,
`id_profesor` int NOT NULL,
`id_curso` int NOT NULL,
`dia_semana`
enum('Lunes','Martes','Miércoles','Jueves','Viernes','Sábado','Domingo') NOT NULL,
`hora_inicio` time NOT NULL,
`hora_fin` time NOT NULL,
`lugar` varchar(100) DEFAULT NULL,
PRIMARY KEY (`id_horario`),
KEY `id_asignatura` (`id_asignatura`),
KEY `id_profesor` (`id_profesor`),
KEY `id_curso` (`id_curso`),
CONSTRAINT `fk_horario_asignatura` FOREIGN KEY (`id_asignatura`) REFERENCES
`asignaturas` (`id_asignatura`) ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT `fk_horario_curso` FOREIGN KEY (`id_curso`) REFERENCES `cursos`
(`id_curso`) ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT `fk_horario_profesor` FOREIGN KEY (`id_profesor`) REFERENCES
`profesores` (`id_profesor`) ON DELETE RESTRICT ON UPDATE CASCADE
) 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 `horarios`
--

LOCK TABLES `horarios` WRITE;


/*!40000 ALTER TABLE `horarios` DISABLE KEYS */;
INSERT INTO `horarios` VALUES (1,1,1,201,'Lunes','12:00:00','13:00:00','Sala 20'),
(2,2,2,202,'Martes','11:00:00','13:00:00','Sala 1');
/*!40000 ALTER TABLE `horarios` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `profesores`
--

DROP TABLE IF EXISTS `profesores`;


/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `profesores` (
`id_profesor` int NOT NULL AUTO_INCREMENT,
`nombre` varchar(50) NOT NULL,
`apellidos` varchar(50) NOT NULL,
`correo` varchar(100) NOT NULL,
`telefono` varchar(20) DEFAULT NULL,
PRIMARY KEY (`id_profesor`),
UNIQUE KEY `correo` (`correo`)
) 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 `profesores`
--

LOCK TABLES `profesores` WRITE;


/*!40000 ALTER TABLE `profesores` DISABLE KEYS */;
INSERT INTO `profesores` VALUES (1,'juan','benito','[email protected]','123456789'),
(2,'Belen','Camapana','[email protected]','987654321');
/*!40000 ALTER TABLE `profesores` ENABLE KEYS */;
UNLOCK TABLES;
/*!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-05-21 22:40:27

You might also like