176 lines
5.2 KiB
SQL
176 lines
5.2 KiB
SQL
DROP DATABASE IF EXISTS lania_cc;
|
|
CREATE DATABASE lania_cc DEFAULT CHARACTER SET utf8mb4;
|
|
USE lania_cc;
|
|
|
|
-- DDL -------------------------------------------------------------------------------------
|
|
CREATE TABLE genero (
|
|
id_genero TINYINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
|
descripcion VARCHAR(20) NOT NULL UNIQUE
|
|
) ENGINE=InnoDB;
|
|
|
|
CREATE TABLE rango_edad (
|
|
id_rango_edad TINYINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
|
descripcion VARCHAR(15) NOT NULL UNIQUE
|
|
) ENGINE=InnoDB;
|
|
|
|
|
|
CREATE TABLE tipo_identificacion (
|
|
id_tipo_id TINYINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
|
descripcion VARCHAR(50) NOT NULL UNIQUE
|
|
) ENGINE=InnoDB;
|
|
|
|
CREATE TABLE nivel_estudio (
|
|
id_nivel TINYINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
|
descripcion VARCHAR(50) NOT NULL UNIQUE
|
|
) ENGINE=InnoDB;
|
|
|
|
CREATE TABLE giro (
|
|
id_giro TINYINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
|
descripcion VARCHAR(100) NOT NULL UNIQUE
|
|
) ENGINE=InnoDB;
|
|
|
|
CREATE TABLE examen (
|
|
id_examen SMALLINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
|
nombre_examen VARCHAR(150) NOT NULL UNIQUE
|
|
) ENGINE=InnoDB;
|
|
|
|
|
|
-- IMPORTAR BASE DE DATOS DE INEGI
|
|
|
|
|
|
-- 1. TABLA CANDIDATO (datos básicos)
|
|
CREATE TABLE candidato (
|
|
id_candidato INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
|
fecha_entrada DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
fecha_salida DATETIME DEFAULT NULL,
|
|
|
|
nombres VARCHAR(100) NOT NULL,
|
|
primer_apellido VARCHAR(100) NOT NULL,
|
|
segundo_apellido VARCHAR(100) DEFAULT NULL,
|
|
|
|
correo VARCHAR(150) NOT NULL,
|
|
telefono VARCHAR(30) NOT NULL,
|
|
|
|
id_examen SMALLINT UNSIGNED NOT NULL,
|
|
id_tipo_id TINYINT UNSIGNED NOT NULL,
|
|
id_rango_edad TINYINT UNSIGNED NOT NULL,
|
|
id_genero TINYINT UNSIGNED NOT NULL,
|
|
|
|
FOREIGN KEY (id_examen) REFERENCES examen(id_examen),
|
|
FOREIGN KEY (id_tipo_id) REFERENCES tipo_identificacion(id_tipo_id),
|
|
FOREIGN KEY (id_rango_edad) REFERENCES rango_edad(id_rango_edad),
|
|
FOREIGN KEY (id_genero) REFERENCES genero(id_genero)
|
|
) ENGINE=InnoDB;
|
|
|
|
-- 2. TABLA INFO_CANDIDATOS (datos extendidos)
|
|
CREATE TABLE info_candidatos (
|
|
id_candidato INT UNSIGNED PRIMARY KEY,
|
|
|
|
id_pais INT NOT NULL,
|
|
id_estado INT DEFAULT NULL,
|
|
id_municipio INT DEFAULT NULL,
|
|
id_colonia INT DEFAULT NULL,
|
|
|
|
id_nivel TINYINT UNSIGNED NOT NULL,
|
|
id_giro TINYINT UNSIGNED NOT NULL,
|
|
|
|
nombre_empresa_institucion VARCHAR(150) NOT NULL,
|
|
motivo_examen VARCHAR(255) NOT NULL,
|
|
|
|
calificacion_servicio TINYINT NOT NULL,
|
|
consentimiento_pub TINYINT NOT NULL,
|
|
|
|
FOREIGN KEY (id_candidato) REFERENCES candidato(id_candidato)
|
|
ON DELETE CASCADE,
|
|
FOREIGN KEY (id_pais) REFERENCES paises(id),
|
|
FOREIGN KEY (id_estado) REFERENCES estados(id),
|
|
FOREIGN KEY (id_municipio) REFERENCES municipios(id),
|
|
FOREIGN KEY (id_colonia) REFERENCES colonias(id),
|
|
FOREIGN KEY (id_nivel) REFERENCES nivel_estudio(id_nivel),
|
|
FOREIGN KEY (id_giro) REFERENCES giro(id_giro)
|
|
) ENGINE=InnoDB;
|
|
|
|
CREATE TABLE usuario (
|
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
usuario VARCHAR(150) UNIQUE NOT NULL,
|
|
contrasena VARCHAR(255) NOT NULL
|
|
) ENGINE=InnoDB;
|
|
|
|
|
|
-- DML -------------------------------------------------------------------------------------
|
|
|
|
-- Inserción catalogo "genero":
|
|
INSERT INTO genero (id_genero, descripcion) VALUES
|
|
(1, 'Masculino'),
|
|
(2, 'Femenino'),
|
|
(3, 'Prefiero no decir');
|
|
|
|
-- Inserción catalogo "rango_edad":
|
|
INSERT INTO rango_edad (id_rango_edad, descripcion) VALUES
|
|
(1, 'Menos de 18'),
|
|
(2, '18-24'),
|
|
(3, '24-34'),
|
|
(4, '35-44'),
|
|
(5, '44-54'),
|
|
(6, '55-64'),
|
|
(7, '65 o más');
|
|
|
|
-- Inserción catalogo "tipo_identificacion":
|
|
INSERT INTO tipo_identificacion (id_tipo_id, descripcion) VALUES
|
|
(1, 'INE'),
|
|
(2, 'Pasaporte'),
|
|
(3, 'CURP'),
|
|
(4, 'RFC'),
|
|
(5, 'Cédula Profesional'),
|
|
(6, 'Licencia de Conducir'),
|
|
(7, 'Otro');
|
|
|
|
-- Inserción catalogo "nivel_estudio":
|
|
INSERT INTO nivel_estudio (id_nivel, descripcion) VALUES
|
|
(1, 'Primaria'),
|
|
(2, 'Secundaria'),
|
|
(3, 'Bachillerato'),
|
|
(4, 'Técnico Superior Universitario'),
|
|
(5, 'Licenciatura'),
|
|
(6, 'Maestría'),
|
|
(7, 'Doctorado'),
|
|
(8, 'Otro');
|
|
|
|
-- Inserción catalogo "giro_empresa" considerando los giros de las empresas más comunes:
|
|
INSERT INTO giro (id_giro, descripcion) VALUES
|
|
(1, 'Tecnologías de la Información'),
|
|
(2, 'Gobierno'),
|
|
(3, 'Finanzas'),
|
|
(4, 'Salud'),
|
|
(5, 'Educación'),
|
|
(6, 'Telecomunicaciones'),
|
|
(7, 'Retail'),
|
|
(8, 'Manufactura'),
|
|
(9, 'Logística y Transporte'),
|
|
(10, 'Construcción'),
|
|
(11, 'Turismo y Hospitalidad'),
|
|
(12, 'Energía y Recursos Naturales'),
|
|
(13, 'Agricultura y Alimentación'),
|
|
(14, 'Medios de Comunicación y Entretenimiento'),
|
|
(15, 'Otros');
|
|
|
|
-- Inserción catalogo "examen" se refiere al nombre de la organización a la que pertence el examen:
|
|
INSERT INTO examen (id_examen, nombre_examen) VALUES
|
|
(1, 'Cisco'),
|
|
(2, 'IBM'),
|
|
(3, 'Microsoft'),
|
|
(4, 'Oracle'),
|
|
(5, 'SAP'),
|
|
(6, 'CompTIA'),
|
|
(7, 'Amazon Web Services'),
|
|
(8, 'Google Cloud Platform'),
|
|
(9, 'Salesforce'),
|
|
(10, 'Red Hat'),
|
|
(11, 'VMware'),
|
|
(12, 'Palo Alto Networks'),
|
|
(13, 'Fortinet'),
|
|
(14, 'Juniper Networks'),
|
|
(15, 'Otros');
|
|
|
|
-- Depues de importar la bd de inegi
|
|
insert into paises(nombre) values('Otro'); |