Sei sulla pagina 1di 25

BASES DE DATOS BASICO

ACT14_301330_29





POR
OSCAR ALBERTO ROMERO RUIZ
CDIGO
80064792






MAYO DE 2014
UNIVERSIDAD NACIONAL ABIERTA Y A DISTANCIA
(UNAD)
ESCUELA DE CIENCIAS BSICAS, TECNOLOGA E INGENIERA




ACT14_301330_29








TUTOR: SRA. MARIA DORA ALBA SANCHEZ
PRESENTADO POR: OSCAR ALBERTO ROMERO
MAYO DE 2014






BOGOT D.C.
BASES DE DATOS BASICO
ESCUELA DE CIENCIAS BSICAS, TECNOLOGA E INGENIERA

UNIVERSIDAD NACIONAL ABIERTA Y A DISTANCIA


DESARROLLO
1 Base de datos INVEVIRUS

a) Creacin del esquema y tablas:

CREATE SCHEMA `invevirus` DEFAULT CHARACTER SET latin1 ;




Scripts de creacin de tablas:


CREATE TABLE actividades_investigacion
(
cons_actividad BIGINT NOT NULL,
nombre_actividad VARCHAR(50),
horas_asignada BIGINT,
horas_reales BIGINT,
auxiliar BIGINT NOT NULL,
cons_proyecto_investigacion BIGINT,
fecha_inicio DATETIME,
fecha_fin DATETIME,
PRIMARY KEY (cons_actividad),
KEY (auxiliar),
KEY (cons_proyecto_investigacion),
KEY (auxiliar)

) ;


CREATE TABLE auxiliares
(
nro_id_auxiliar BIGINT NOT NULL,
tipo_documento_identificacion VARCHAR(5) NOT NULL,
numero_documento_identificacion VARCHAR(50) NOT NULL,
nombres VARCHAR(50) NOT NULL,
apellidos VARCHAR(50),
cod_pais BIGINT,
direccion VARCHAR(50),
telefono VARCHAR(50),
sexo VARCHAR(1) NOT NULL,
fecha_nacimiento DATETIME,
estado_civil VARCHAR(20)NOT NULL,
cod_pregrado BIGINT,
cod_grupo_investigacion BIGINT,
PRIMARY KEY (nro_id_auxiliar),
UNIQUE
UQ_colaboradores_numero_documento_identificacion(numero_documento_
identificacion),
KEY (cod_grupo_investigacion),
KEY (cod_pais),
KEY (cod_pregrado),
KEY (estado_civil),
KEY (cod_pais),
KEY (tipo_documento_identificacion)

) ;


CREATE TABLE ciudades
(
cod_ciudad BIGINT NOT NULL,
nombre_ciudad VARCHAR(50) NOT NULL,
cod_pais BIGINT NOT NULL,
PRIMARY KEY (cod_ciudad),
UNIQUE UQ_ciudades_nombre_ciudad(nombre_ciudad),
KEY (cod_pais)

) ;


CREATE TABLE grupos_investigacion
(
cod_grupo_investigacion BIGINT NOT NULL,
nombre_grupo VARCHAR(50) NOT NULL,
cod_ciudad BIGINT NOT NULL,
director_grupo BIGINT NOT NULL,
clasificacion_colciencias VARCHAR(50),
grupo_padre BIGINT,
tipo_grupo VARCHAR(50),
PRIMARY KEY (cod_grupo_investigacion),
UNIQUE
UQ_grupos_investigacion_codigo_grupo_investigacion(codigo_grupo_in
vestigacion),
UNIQUE UQ_grupos_investigacion_nombre_grupo(nombre_grupo),
KEY (cod_ciudad),
KEY (director_grupo),
KEY (grupo_padre)

) ;


CREATE TABLE investigadores
(
nro_id_investigador BIGINT NOT NULL,
tipo_documento VARCHAR(50),
numero_documento_identificacion VARCHAR(50) NOT NULL,
nombres VARCHAR(50) NOT NULL,
apellidos VARCHAR(50),
cod_pais BIGINT,
cod_ciudad BIGINT,
direccion VARCHAR(50),
telefono VARCHAR(50),
sexo VARCHAR(1) NOT NULL,
fecha_nacimiento DATETIME,
estado_civil VARCHAR(50),
PRIMARY KEY (nro_id_investigador),
UNIQUE
UQ_colaboradores_numero_documento_identificacion(numero_documento_
identificacion),
KEY (cod_ciudad),
KEY (cod_pais)

) ;


CREATE TABLE lineas_investigacion
(
cod_linea_investigacion BIGINT NOT NULL,
nombre VARCHAR(50),
grupo_investigacion_adscrito BIGINT,
tema VARCHAR(50),
linea_padre BIGINT,
PRIMARY KEY (cod_linea_investigacion),
KEY (grupo_investigacion_adscrito),
KEY (linea_padre)

) ;


CREATE TABLE paises
(
cod_pais BIGINT NOT NULL,
nombre_pais VARCHAR(50) NOT NULL,
PRIMARY KEY (cod_pais),
UNIQUE UQ_paises_nombre_pais(nombre_pais)

) ;


CREATE TABLE postgrados
(
cod_titulo BIGINT NOT NULL,
nombre_titulo VARCHAR(50) NOT NULL,
tipo_postgrado VARCHAR(50),
PRIMARY KEY (cod_titulo),
UNIQUE UQ_titulos_postgrado_nombre_titulo(nombre_titulo)

) ;


CREATE TABLE postgrados_investigadores
(
nro_id_investigador BIGINT NOT NULL,
cod_postgrado BIGINT NOT NULL,
PRIMARY KEY (nro_id_investigador, cod_postgrado),
UNIQUE
UQ_postgrados_investigadores_cod_postgrado(cod_postgrado),
UNIQUE
UQ_postgrados_investigadores_nro_id_investigador(nro_id_investigad
or),
KEY (nro_id_investigador),
KEY (cod_postgrado)

) ;


CREATE TABLE pregrados
(
cod_pregrado BIGINT NOT NULL,
nombre_pregrado VARCHAR(50) NOT NULL,
tipo_pregrado VARCHAR(50),
PRIMARY KEY (cod_pregrado),
UNIQUE UQ_pregrados_nombre_pregrado(nombre_pregrado)

) ;


CREATE TABLE pregrados_investigadores
(
nro_id_investigador BIGINT NOT NULL,
cod_pregrado BIGINT NOT NULL,
PRIMARY KEY (nro_id_investigador, cod_pregrado),
UNIQUE
UQ_pregrados_investigadores_cod_pregrado(cod_pregrado),
UNIQUE
UQ_pregrados_investigadores_nro_id_investigador(nro_id_investigado
r),
KEY (nro_id_investigador),
KEY (cod_pregrado)

) ;


CREATE TABLE productos
(
consecutivo_producto BIGINT NOT NULL,
fecha_realizacion DATETIME NOT NULL,
resumen VARCHAR(50),
autor BIGINT NOT NULL,
nombre_evento VARCHAR(50),
numero VARCHAR(50),
editorial VARCHAR(50),
cons_proyecto_invenstigacion BIGINT,
tipo_producto VARCHAR(50),
PRIMARY KEY (consecutivo_producto),
KEY (autor),
KEY (cons_proyecto_invenstigacion)

) ;


CREATE TABLE proyectos_investigacion
(
cons_proyecto_investigacion BIGINT NOT NULL,
titulo VARCHAR(50),
director_investigacion BIGINT NOT NULL,
linea_investigacion BIGINT NOT NULL,
numero_comite_aprobacion BIGINT NOT NULL,
fecha_inicial DATETIME,
fecha_final DATETIME,
presupuesto DECIMAL(10,2),
grupo_investigacion BIGINT,
fecha_aprovacion DATETIME,
PRIMARY KEY (cons_proyecto_investigacion),
UNIQUE UQ_proyectos_investigacion_titulo(titulo),
KEY (director_investigacion),
KEY (grupo_investigacion),
KEY (linea_investigacion)

)
;



SET FOREIGN_KEY_CHECKS=1;


ALTER TABLE actividades_investigacion ADD CONSTRAINT
FK_actividades_investigacion_auxiliares
FOREIGN KEY (auxiliar) REFERENCES auxiliares
(nro_id_auxiliar);

ALTER TABLE actividades_investigacion ADD CONSTRAINT
FK_actividades_investigacion_proyectos_investigacion
FOREIGN KEY (cons_proyecto_investigacion) REFERENCES
proyectos_investigacion (cons_proyecto_investigacion);

ALTER TABLE actividades_investigacion ADD CONSTRAINT
FK_actividades_proyecto_colaboradores
FOREIGN KEY (auxiliar) REFERENCES investigadores
(nro_id_investigador);

ALTER TABLE auxiliares ADD CONSTRAINT
FK_auxiliares_grupos_investigacion
FOREIGN KEY (cod_grupo_investigacion) REFERENCES
grupos_investigacion (cod_grupo_investigacion);

ALTER TABLE auxiliares ADD CONSTRAINT FK_auxiliares_paises
FOREIGN KEY (cod_pais) REFERENCES paises (cod_pais);

ALTER TABLE auxiliares ADD CONSTRAINT FK_auxiliares_pregrados
FOREIGN KEY (cod_pregrado) REFERENCES pregrados
(cod_pregrado);

ALTER TABLE ciudades ADD CONSTRAINT FK_ciudades_paises
FOREIGN KEY (cod_pais) REFERENCES paises (cod_pais);

ALTER TABLE grupos_investigacion ADD CONSTRAINT
FK_grupos_investigacion_ciudades
FOREIGN KEY (cod_ciudad) REFERENCES ciudades (cod_ciudad);

ALTER TABLE grupos_investigacion ADD CONSTRAINT
FK_grupos_investigacion_colaboradores
FOREIGN KEY (director_grupo) REFERENCES investigadores
(nro_id_investigador);

ALTER TABLE grupos_investigacion ADD CONSTRAINT
FK_grupos_investigacion_grupos_investigacion
FOREIGN KEY (grupo_padre) REFERENCES grupos_investigacion
(cod_grupo_investigacion);

ALTER TABLE investigadores ADD CONSTRAINT
FK_investigadores_ciudades
FOREIGN KEY (cod_ciudad) REFERENCES ciudades (cod_ciudad);

ALTER TABLE investigadores ADD CONSTRAINT FK_investigadores_paises
FOREIGN KEY (cod_pais) REFERENCES paises (cod_pais);

ALTER TABLE lineas_investigacion ADD CONSTRAINT
FK_lineas_investigacion_grupos_investigacion
FOREIGN KEY (grupo_investigacion_adscrito) REFERENCES
grupos_investigacion (cod_grupo_investigacion);

ALTER TABLE lineas_investigacion ADD CONSTRAINT
FK_lineas_investigacion_lineas_investigacion
FOREIGN KEY (linea_padre) REFERENCES lineas_investigacion
(cod_linea_investigacion);

ALTER TABLE postgrados_investigadores ADD CONSTRAINT
FK_colaboradores_titulos_postgrados_colaboradores
FOREIGN KEY (nro_id_investigador) REFERENCES investigadores
(nro_id_investigador);

ALTER TABLE postgrados_investigadores ADD CONSTRAINT
FK_colaboradores_titulos_postgrados_titulos_postgrado
FOREIGN KEY (cod_postgrado) REFERENCES postgrados
(cod_titulo);

ALTER TABLE pregrados_investigadores ADD CONSTRAINT
FK_colaboradores_titulos_pregrado_colaboradores
FOREIGN KEY (nro_id_investigador) REFERENCES investigadores
(nro_id_investigador);

ALTER TABLE pregrados_investigadores ADD CONSTRAINT
FK_colaboradores_titulos_pregrado_titulos_pregrado
FOREIGN KEY (cod_pregrado) REFERENCES pregrados
(cod_pregrado);

ALTER TABLE productos ADD CONSTRAINT FK_productos_colaboradores
FOREIGN KEY (autor) REFERENCES investigadores
(nro_id_investigador);

ALTER TABLE productos ADD CONSTRAINT
FK_productos_proyectos_investigacion
FOREIGN KEY (cons_proyecto_invenstigacion) REFERENCES
proyectos_investigacion (cons_proyecto_investigacion);

ALTER TABLE proyectos_investigacion ADD CONSTRAINT
FK_proyectos_investigacion_colaboradores
FOREIGN KEY (director_investigacion) REFERENCES
investigadores (nro_id_investigador);

ALTER TABLE proyectos_investigacion ADD CONSTRAINT
FK_proyectos_investigacion_grupos_investigacion
FOREIGN KEY (grupo_investigacion) REFERENCES
grupos_investigacion (cod_grupo_investigacion);

ALTER TABLE proyectos_investigacion ADD CONSTRAINT
FK_proyectos_investigacion_lineas_investigacion
FOREIGN KEY (linea_investigacion) REFERENCES
lineas_investigacion (cod_linea_investigacion);







b) Modificacin de una tabla:

ALTER table pregrados add column universidad varchar(250);







c) Registro de valores iniciales:

-- Paises

INSERT INTO `invevirus`.`paises`
(`cod_pais`, `nombre_pais`)
VALUES (1, 'Pais 1');

INSERT INTO `invevirus`.`paises`
(`cod_pais`, `nombre_pais`)
VALUES (2, 'Pais 2');

INSERT INTO `invevirus`.`paises`
(`cod_pais`, `nombre_pais`)
VALUES (3, 'Pais 3');

INSERT INTO `invevirus`.`paises`
(`cod_pais`, `nombre_pais`)
VALUES (4, 'Pais 4');

INSERT INTO `invevirus`.`paises`
(`cod_pais`, `nombre_pais`)
VALUES (5, 'Pais 5');

-- Ciudades

INSERT INTO `invevirus`.`ciudades`
(`cod_ciudad`, `nombre_ciudad`, `cod_pais`)
VALUES (1, 'Ciudad 1', 1);

INSERT INTO `invevirus`.`ciudades`
(`cod_ciudad`, `nombre_ciudad`, `cod_pais`)
VALUES (2, 'Ciudad 2', 2);

INSERT INTO `invevirus`.`ciudades`
(`cod_ciudad`, `nombre_ciudad`, `cod_pais`)
VALUES (3, 'Ciudad 3', 3);

INSERT INTO `invevirus`.`ciudades`
(`cod_ciudad`, `nombre_ciudad`, `cod_pais`)
VALUES (4, 'Ciudad 4', 4);

INSERT INTO `invevirus`.`ciudades`
(`cod_ciudad`, `nombre_ciudad`, `cod_pais`)
VALUES (5, 'Ciudad 5', 5);



-- Postgrados

INSERT INTO `invevirus`.`postgrados`
(`cod_titulo`, `nombre_titulo`, `tipo_postgrado`)
VALUES (1, 'Pregrado 1', 'Tipo 1');

INSERT INTO `invevirus`.`postgrados`
(`cod_titulo`, `nombre_titulo`, `tipo_postgrado`)
VALUES (2, 'Pregrado 2', 'Tipo 2');

INSERT INTO `invevirus`.`postgrados`
(`cod_titulo`, `nombre_titulo`, `tipo_postgrado`)
VALUES (3, 'Pregrado 3', 'Tipo 3');

INSERT INTO `invevirus`.`postgrados`
(`cod_titulo`, `nombre_titulo`, `tipo_postgrado`)
VALUES (4, 'Pregrado 4', 'Tipo 4');

INSERT INTO `invevirus`.`postgrados`
(`cod_titulo`, `nombre_titulo`, `tipo_postgrado`)
VALUES (5, 'Pregrado 5', 'Tipo 5');


-- Pregrados

INSERT INTO `invevirus`.`pregrados`
(`cod_pregrado`, `nombre_pregrado`, `tipo_pregrado`, `universidad`)
VALUES (1, 'Pregrado 1', 'Tipo 1', 'Universidad 1');

INSERT INTO `invevirus`.`pregrados`
(`cod_pregrado`, `nombre_pregrado`, `tipo_pregrado`, `universidad`)
VALUES (2, 'Pregrado 2', 'Tipo 2', 'Universidad 2');

INSERT INTO `invevirus`.`pregrados`
(`cod_pregrado`, `nombre_pregrado`, `tipo_pregrado`, `universidad`)
VALUES (3, 'Pregrado 3', 'Tipo 3', 'Universidad 3');

INSERT INTO `invevirus`.`pregrados`
(`cod_pregrado`, `nombre_pregrado`, `tipo_pregrado`, `universidad`)
VALUES (4, 'Pregrado 4', 'Tipo 4', 'Universidad 4');

INSERT INTO `invevirus`.`pregrados`
(`cod_pregrado`, `nombre_pregrado`, `tipo_pregrado`, `universidad`)
VALUES (5, 'Pregrado 5', 'Tipo 5', 'Universidad 5');


-- Investigadores

INSERT INTO `invevirus`.`investigadores`
(`nro_id_investigador`, `tipo_documento`,
`numero_documento_identificacion`,
`nombres`, `apellidos`, `cod_pais`,
`cod_ciudad`, `direccion`, `telefono`, `sexo`,
`fecha_nacimiento`, `estado_civil`)
VALUES (1, 'CC', '10201545', 'Investigador 1',
'Apellido 1', 1, 1, 'Direccin 1',
'1254564545', 'M', '2000-01-01', 'SOLETERO');


INSERT INTO `invevirus`.`investigadores`
(`nro_id_investigador`, `tipo_documento`,
`numero_documento_identificacion`,
`nombres`, `apellidos`, `cod_pais`,
`cod_ciudad`, `direccion`, `telefono`, `sexo`,
`fecha_nacimiento`, `estado_civil`)
VALUES (2, 'CC', '10201541', 'Investigador 2',
'Apellido 2', 2, 2, 'Direccin 2',
'1254564544', 'M', '2002-02-02', 'SOLETERO');

INSERT INTO `invevirus`.`investigadores`
(`nro_id_investigador`, `tipo_documento`,
`numero_documento_identificacion`,
`nombres`, `apellidos`, `cod_pais`,
`cod_ciudad`, `direccion`, `telefono`, `sexo`,
`fecha_nacimiento`, `estado_civil`)
VALUES (3, 'CC', '10201544', 'Investigador 3',
'Apellido 3', 3, 3, 'Direccin 3',
'1254564543', 'M', '2003-03-03', 'SOLETERO');

INSERT INTO `invevirus`.`investigadores`
(`nro_id_investigador`, `tipo_documento`,
`numero_documento_identificacion`,
`nombres`, `apellidos`, `cod_pais`,
`cod_ciudad`, `direccion`, `telefono`, `sexo`,
`fecha_nacimiento`, `estado_civil`)
VALUES (4, 'CC', '10201543', 'Investigador 4',
'Apellido 4', 4, 4, 'Direccin 4',
'1254564545', 'M', '2004-04-04', 'SOLETERO');

INSERT INTO `invevirus`.`investigadores`
(`nro_id_investigador`, `tipo_documento`,
`numero_documento_identificacion`,
`nombres`, `apellidos`, `cod_pais`,
`cod_ciudad`, `direccion`, `telefono`, `sexo`,
`fecha_nacimiento`, `estado_civil`)
VALUES (5, 'CC', '10201542', 'Investigador 5',
'Apellido 5', 5, 5, 'Direccin 5',
'1254564545', 'M', '2005-01-01', 'CASADO');

-- postgrados investigadores

INSERT INTO `invevirus`.`postgrados_investigadores`
(`nro_id_investigador`, `cod_postgrado`)
VALUES (1, 1);

INSERT INTO `invevirus`.`postgrados_investigadores`
(`nro_id_investigador`, `cod_postgrado`)
VALUES (2, 2);

INSERT INTO `invevirus`.`postgrados_investigadores`
(`nro_id_investigador`, `cod_postgrado`)
VALUES (3, 3);

INSERT INTO `invevirus`.`postgrados_investigadores`
(`nro_id_investigador`, `cod_postgrado`)
VALUES (4, 4);

INSERT INTO `invevirus`.`postgrados_investigadores`
(`nro_id_investigador`, `cod_postgrado`)
VALUES (5, 5);

-- Pregrados investigadores

INSERT INTO `invevirus`.`pregrados_investigadores`
(`nro_id_investigador`, `cod_pregrado`)
VALUES (1, 1);

INSERT INTO `invevirus`.`pregrados_investigadores`
(`nro_id_investigador`, `cod_pregrado`)
VALUES (2, 2);

INSERT INTO `invevirus`.`pregrados_investigadores`
(`nro_id_investigador`, `cod_pregrado`)
VALUES (3, 3);

INSERT INTO `invevirus`.`pregrados_investigadores`
(`nro_id_investigador`, `cod_pregrado`)
VALUES (4, 4);

INSERT INTO `invevirus`.`pregrados_investigadores`
(`nro_id_investigador`, `cod_pregrado`)
VALUES (5, 5);


-- Grupos de investigacin

INSERT INTO `invevirus`.`grupos_investigacion`
(`cod_grupo_investigacion`, `nombre_grupo`,
`cod_ciudad`, `director_grupo`, `clasificacion_colciencias`,
`grupo_padre`, `tipo_grupo`)
VALUES (1, 'Grupo 1', 1, 1, 'A', null, 'Tipo Grupo 1');

INSERT INTO `invevirus`.`grupos_investigacion`
(`cod_grupo_investigacion`, `nombre_grupo`,
`cod_ciudad`, `director_grupo`, `clasificacion_colciencias`,
`grupo_padre`, `tipo_grupo`)
VALUES (2, 'Grupo 2', 2, 2, 'B', null, 'Tipo Grupo 2');

INSERT INTO `invevirus`.`grupos_investigacion`
(`cod_grupo_investigacion`, `nombre_grupo`,
`cod_ciudad`, `director_grupo`, `clasificacion_colciencias`,
`grupo_padre`, `tipo_grupo`)
VALUES (3, 'Grupo 3', 3, 3, 'A', null, 'Tipo Grupo 3');

INSERT INTO `invevirus`.`grupos_investigacion`
(`cod_grupo_investigacion`, `nombre_grupo`,
`cod_ciudad`, `director_grupo`, `clasificacion_colciencias`,
`grupo_padre`, `tipo_grupo`)
VALUES (4, 'Grupo 4', 4, 4, 'C', null, 'Tipo Grupo 1');

INSERT INTO `invevirus`.`grupos_investigacion`
(`cod_grupo_investigacion`, `nombre_grupo`,
`cod_ciudad`, `director_grupo`, `clasificacion_colciencias`,
`grupo_padre`, `tipo_grupo`)
VALUES (5, 'Grupo 5', 5, 5, 'D', null, 'Tipo Grupo 5');


-- Auxiliares

INSERT INTO `invevirus`.`auxiliares`
(`nro_id_auxiliar`, `tipo_documento_identificacion`,
`numero_documento_identificacion`, `nombres`, `apellidos`,
`cod_pais`, `direccion`, `telefono`, `sexo`, `fecha_nacimiento`,
`estado_civil`, `cod_pregrado`, `cod_grupo_investigacion`)
VALUES (1, 'CC', '8004545451', 'Auxiliar 1', 'Perez',
'01', 'AV CALLE', '245454544', 'M',
'2015-01-01', 'SOLETERO', 1, 1);


INSERT INTO `invevirus`.`auxiliares`
(`nro_id_auxiliar`, `tipo_documento_identificacion`,
`numero_documento_identificacion`, `nombres`, `apellidos`,
`cod_pais`, `direccion`, `telefono`, `sexo`, `fecha_nacimiento`,
`estado_civil`, `cod_pregrado`, `cod_grupo_investigacion`)
VALUES (2, 'CC', '8004545452', 'Auxiliar 2', 'Perez',
'01', 'AV CALLE', '245454544', 'M',
'2015-01-01', 'SOLETERO', 1, 1);

INSERT INTO `invevirus`.`auxiliares`
(`nro_id_auxiliar`, `tipo_documento_identificacion`,
`numero_documento_identificacion`, `nombres`, `apellidos`,
`cod_pais`, `direccion`, `telefono`, `sexo`, `fecha_nacimiento`,
`estado_civil`, `cod_pregrado`, `cod_grupo_investigacion`)
VALUES (3, 'CC', '80045454543', 'Auxiliar 3', 'Perez',
'03', 'AV CALLE', '245454544', 'M',
'2013-03-03', 'SOLETERO', 3, 3);

INSERT INTO `invevirus`.`auxiliares`
(`nro_id_auxiliar`, `tipo_documento_identificacion`,
`numero_documento_identificacion`, `nombres`, `apellidos`,
`cod_pais`, `direccion`, `telefono`, `sexo`, `fecha_nacimiento`,
`estado_civil`, `cod_pregrado`, `cod_grupo_investigacion`)
VALUES (4, 'CC', '80045454544', 'Auxiliar 4', 'Perez',
'04', 'AV CALLE', '245454544', 'M',
'2014-04-04', 'SOLETERO', 4, 4);

INSERT INTO `invevirus`.`auxiliares`
(`nro_id_auxiliar`, `tipo_documento_identificacion`,
`numero_documento_identificacion`, `nombres`, `apellidos`,
`cod_pais`, `direccion`, `telefono`, `sexo`, `fecha_nacimiento`,
`estado_civil`, `cod_pregrado`, `cod_grupo_investigacion`)
VALUES (5, 'CC', '80045454545', 'Auxiliar 5', 'Perez',
'01', 'AV CALLE', '245454544', 'M',
'2015-05-05', 'SOLETERO', 5, 5);


-- Lneas de investigacin

INSERT INTO `invevirus`.`lineas_investigacion`
(`cod_linea_investigacion`, `nombre`,
`grupo_investigacion_adscrito`, `tema`, `linea_padre`)
VALUES (1, 'Lnea 1', 1, 'Tema 1', null);

INSERT INTO `invevirus`.`lineas_investigacion`
(`cod_linea_investigacion`, `nombre`,
`grupo_investigacion_adscrito`, `tema`, `linea_padre`)
VALUES (2, 'Lnea 2', 2, 'Tema 2', null);

INSERT INTO `invevirus`.`lineas_investigacion`
(`cod_linea_investigacion`, `nombre`,
`grupo_investigacion_adscrito`, `tema`, `linea_padre`)
VALUES (3, 'Lnea 3', 3, 'Tema 3', null);

INSERT INTO `invevirus`.`lineas_investigacion`
(`cod_linea_investigacion`, `nombre`,
`grupo_investigacion_adscrito`, `tema`, `linea_padre`)
VALUES (4, 'Lnea 4', 4, 'Tema 4', null);

INSERT INTO `invevirus`.`lineas_investigacion`
(`cod_linea_investigacion`, `nombre`,
`grupo_investigacion_adscrito`, `tema`, `linea_padre`)
VALUES (5, 'Lnea 5', 5, 'Tema 5', null);


-- Proyectos de investigacion

INSERT INTO `invevirus`.`proyectos_investigacion`
(`cons_proyecto_investigacion`, `titulo`, `director_investigacion`,
`linea_investigacion`, `numero_comite_aprobacion`, `fecha_inicial`,
`fecha_final`, `presupuesto`, `grupo_investigacion`, `fecha_aprovacion`)
VALUES (1, 'Proyecto 1', 1, 1, 1, '2010-01-01', '2020-01-01',
'50454510', 1, '2010-01-01');

INSERT INTO `invevirus`.`proyectos_investigacion`
(`cons_proyecto_investigacion`, `titulo`, `director_investigacion`,
`linea_investigacion`, `numero_comite_aprobacion`, `fecha_inicial`,
`fecha_final`, `presupuesto`, `grupo_investigacion`, `fecha_aprovacion`)
VALUES (2, 'Proyecto 2', 2, 2, 2, '2012-01-01', '2022-01-01',
'50454510', 2, '2012-01-02');

INSERT INTO `invevirus`.`proyectos_investigacion`
(`cons_proyecto_investigacion`, `titulo`, `director_investigacion`,
`linea_investigacion`, `numero_comite_aprobacion`, `fecha_inicial`,
`fecha_final`, `presupuesto`, `grupo_investigacion`, `fecha_aprovacion`)
VALUES (3, 'Proyecto 3', 3, 3, 3, '2013-01-01', '2023-01-01',
'50454510', 3, '2013-01-01');

INSERT INTO `invevirus`.`proyectos_investigacion`
(`cons_proyecto_investigacion`, `titulo`, `director_investigacion`,
`linea_investigacion`, `numero_comite_aprobacion`, `fecha_inicial`,
`fecha_final`, `presupuesto`, `grupo_investigacion`, `fecha_aprovacion`)
VALUES (4, 'Proyecto 4', 4, 4, 4, '2014-01-01', '2024-01-04',
'50454510', 4, '2010-04-04');

INSERT INTO `invevirus`.`proyectos_investigacion`
(`cons_proyecto_investigacion`, `titulo`, `director_investigacion`,
`linea_investigacion`, `numero_comite_aprobacion`, `fecha_inicial`,
`fecha_final`, `presupuesto`, `grupo_investigacion`, `fecha_aprovacion`)
VALUES (5, 'Proyecto 5', 5, 5, 5, '2015-05-05', '2025-05-05',
'50454515', 5, '2015-05-05');


-- Actividades de investigacin

INSERT INTO `invevirus`.`actividades_investigacion`
(`cons_actividad`, `nombre_actividad`,
`horas_asignada`, `horas_reales`,
`auxiliar`, `cons_proyecto_investigacion`,
`fecha_inicio`, `fecha_fin`)
VALUES (1, 'Actividad 1', 500, 200, 1, 1,
'2014-01-01', '2015-01-01');

INSERT INTO `invevirus`.`actividades_investigacion`
(`cons_actividad`, `nombre_actividad`,
`horas_asignada`, `horas_reales`,
`auxiliar`, `cons_proyecto_investigacion`,
`fecha_inicio`, `fecha_fin`)
VALUES (2, 'Actividad 2', 600, 200, 1, 1,
'2014-02-01', '2012-01-01');

INSERT INTO `invevirus`.`actividades_investigacion`
(`cons_actividad`, `nombre_actividad`,
`horas_asignada`, `horas_reales`,
`auxiliar`, `cons_proyecto_investigacion`,
`fecha_inicio`, `fecha_fin`)
VALUES (3, 'Actividad 3', 500, 300, 3, 3,
'2013-03-01', '2013-01-03');

INSERT INTO `invevirus`.`actividades_investigacion`
(`cons_actividad`, `nombre_actividad`,
`horas_asignada`, `horas_reales`,
`auxiliar`, `cons_proyecto_investigacion`,
`fecha_inicio`, `fecha_fin`)
VALUES (4, 'Actividad 1', 400, 200, 4, 4,
'2014-04-01', '2014-01-01');

INSERT INTO `invevirus`.`actividades_investigacion`
(`cons_actividad`, `nombre_actividad`,
`horas_asignada`, `horas_reales`,
`auxiliar`, `cons_proyecto_investigacion`,
`fecha_inicio`, `fecha_fin`)
VALUES (5, 'Actividad 5', 500, 200, 5, 5,
'2015-01-01', '2015-01-01');


-- Productos

INSERT INTO `invevirus`.`productos`
(`consecutivo_producto`, `fecha_realizacion`, `resumen`,
`autor`, `nombre_evento`, `numero`, `editorial`,
`cons_proyecto_invenstigacion`, `tipo_producto`)
VALUES (1, '2010-01-01', 'Resumen 1', 1,
'Eventto 1', 'Nmero 1', 'Editorial 1', 1, 'Revista 1');

INSERT INTO `invevirus`.`productos`
(`consecutivo_producto`, `fecha_realizacion`, `resumen`,
`autor`, `nombre_evento`, `numero`, `editorial`,
`cons_proyecto_invenstigacion`, `tipo_producto`)
VALUES (2, '2012-01-01', 'Resumen 2', 2,
'Evento 2', 'Nmero 2', 'Editorial 2', 2, 'Revista 2');

INSERT INTO `invevirus`.`productos`
(`consecutivo_producto`, `fecha_realizacion`, `resumen`,
`autor`, `nombre_evento`, `numero`, `editorial`,
`cons_proyecto_invenstigacion`, `tipo_producto`)
VALUES (3, '2013-01-01', 'Resumen 3', 3,
'Evento 3', 'Nmero 3', 'Editorial 3', 3, 'Revista 3');

INSERT INTO `invevirus`.`productos`
(`consecutivo_producto`, `fecha_realizacion`, `resumen`,
`autor`, `nombre_evento`, `numero`, `editorial`,
`cons_proyecto_invenstigacion`, `tipo_producto`)
VALUES (4, '2014-01-01', 'Resumen 4', 4,
'Evento 4', 'Nmero 4', 'Editorial 4', 4, 'Revista 4');

INSERT INTO `invevirus`.`productos`
(`consecutivo_producto`, `fecha_realizacion`, `resumen`,
`autor`, `nombre_evento`, `numero`, `editorial`,
`cons_proyecto_invenstigacion`, `tipo_producto`)
VALUES (5, '2015-01-01', 'Resumen 5', 5,
'Evento 5', 'Nmero 5', 'Editorial 5', 5, 'Revista 5');






d) Eliminacin de registro en la tabla actividades investigacin:

DELETE FROM `invevirus`.`actividades_investigacion` WHERE auxiliar = 1;




e) Actualizacin de la tabla auxiliares

UPDATE `invevirus`.`auxiliares`
SET
`cod_pregrado` = 2,
`cod_grupo_investigacion` = 2
WHERE `nro_id_auxiliar` = 1;





2- Consultas:

a) Se requiere el nombre de los Investigadores que tomaron participaron en el
proyecto de Investigacin El virus loco.


select i.nombres, i.apellidos from investigadores i, proyectos_investigacion p
where i.nro_id_investigador = p.director_investigacion
and p.titulo = 'El virus loco';


b) Se requiere el nombre de los grupos de investigacin con los nombres de
las lneas de investigacin

select g.nombre_grupo, l.nombre from grupos_investigacion g, lineas_investigacion l
where l.grupo_investigacion_adscrito = g.cod_grupo_investigacion;


c) Se requiere saber el nombre de los proyectos de investigacin con los
investigadores participantes, organizados por nombre de proyecto


select p.titulo, i.nombres, i.apellidos
from investigadores i, proyectos_investigacion p
where i.nro_id_investigador = p.director_investigacion
order by p.titulo;


d) Se desea saber el nombre de los grupos con su respectiva cantidad total
de investigaciones realizadas. Solo aquellos grupos que tuvieron ms de
3 investigaciones.

select g.nombre_grupo, count(1) total
from grupos_investigacion g, proyectos_investigacion p
where g.cod_grupo_investigacion = p.grupo_investigacion
group by g.nombre_grupo
having total >= 3;

Potrebbero piacerti anche