Está en la página 1de 8

LABORATORIO 2.

SQL SERVER - BASE DE


DATOS SECRETARIA DEL MEDIO AMBIENTE

BASE DE DATOS SECRETARIA DEL MEDIO AMBIENTE

Presenta información sobre indicadores ambientales en las áreas del


municipio, para diferentes recursos naturales.

FAVA - Formación en Ambientes Virtuales de Aprendizaje SENA - Servicio Nacional de Aprendizaje


Base de datos secretaria del medio ambiente - SQL SERVER

SCRIPT POSTGRESQL

/* Crear la Base de Datos Recreación */


USE MASTER
GO
/****** Object: Database [RECREACION] ******/
IF NOT EXISTS (SELECT name FROM sys.databases WHERE name =
N’RECREACION’)
BEGIN
CREATE DATABASE RECREACION
END
go
/* Poner en uso la Base de Datos */
use RECREACION
go

/* Crear la Tabla Institución*/


IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_
ID(N’[dbo].[Institucion]’) AND type in (N’U’))
BEGIN
CREATE TABLE Institucion(
CodIns Int IDENTITY(1,1) PRIMARY KEY,
NomIns varchar(30) NOT NULL,
DirIns varchar(30) NOT NULL,
TelIns varchar(15) NOT NULL);
END
GO
/* Crear la Tabla Tipo */
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_
ID(N’[dbo].[Tipo]’) AND type in (N’U’))
BEGIN
CREATE TABLE Tipo(
CodTipo Int IDENTITY(1,1) PRIMARY KEY,
NomTipo varchar(30)NOT NULL);
END
GO
/* Crear la Tabla Evento */
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_
ID(N’[dbo].[Evento]’) AND type in (N’U’))
BEGIN
CREATE TABLE Evento(
CodEve Int IDENTITY(1,1) PRIMARY KEY,
NomEve varchar(60) NOT NULL,
CodTipo Int REFERENCES Tipo(CodTipo) NOT NULL,
FechIni Datetime NOT NULL,
FechFin Datetime NOT NULL);

2
FAVA - Formación en Ambientes Virtuales de Aprendizaje SENA - Servicio Nacional de Aprendizaje
Base de datos secretaria del medio ambiente - SQL SERVER

END
GO
/* Crear la Tabla Institucion_Evento */
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_
ID(N’[dbo].[Institucion_Evento]’) AND type in (N’U’))
BEGIN
CREATE TABLE Institucion_Evento(
CodSec Int IDENTITY(1,1) PRIMARY KEY,
CodEve Int REFERENCES Evento(CodEve) NOT NULL,
CodIns Int REFERENCES Institucion(CodIns) NOT NULL);
END
go
/* Crear la Tabla Participante */
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_
ID(N’[dbo].[Participante]’) AND type in (N’U’))
BEGIN
CREATE TABLE Participante(
CodPar Int IDENTITY(1,1) PRIMARY KEY,
NomPar varchar(30) NOT NULL,
ApePar varchar(30) NOT NULL,
IdPar varchar(30) NOT NULL,
EdadPar smallint NOT NULL,
FotoPar image);
END
GO
/* Crear la Tabla Participante_Evento */
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_
ID(N’[dbo].[Participante_Evento]’) AND type in (N’U’))
BEGIN

CREATE TABLE Participante_Evento(


CodSec Int IDENTITY(1,1) PRIMARY KEY,
CodEve Int REFERENCES Evento(CodEve) NOT NULL,
CodPar Int REFERENCES Participante(CodPar) NOT NULL,
ValIns money);
END
GO
/* Datos para la tabla Institucion */
INSERT INTO Institucion(NomIns,DirIns,TelIns) VALUES(‘Prodeportes’,’Cra 3
Nro 4-24’,’8701020’);
INSERT INTO Institucion(NomIns,DirIns,TelIns) VALUES(‘La Esperanza’,’Cra 10
Nro 20-11’,’8721024’);
INSERT INTO Institucion(NomIns,DirIns,TelIns) VALUES(‘Unidos por la
Paz’,’Cra 6 Nro 7-24’,’8731028’);
INSERT INTO Institucion(NomIns,DirIns,TelIns) VALUES(‘Las Estrellas’,’Cra 3
Nro 9-24’,’8761040’);

3
FAVA - Formación en Ambientes Virtuales de Aprendizaje SENA - Servicio Nacional de Aprendizaje
Base de datos secretaria del medio ambiente - SQL SERVER

INSERT INTO Institucion(NomIns,DirIns,TelIns) VALUES(‘La Catleya’,’Cra 3 Nro


5-27’,’8751220’);
INSERT INTO Institucion(NomIns,DirIns,TelIns) VALUES(‘La Nueva Ola’,’Cra 3
Nro 6-24’,’8741044’);
INSERT INTO Institucion(NomIns,DirIns,TelIns) VALUES(‘Salva una Vida’,’Cra 3
Nro 7-24’,’8731121’);
INSERT INTO Institucion(NomIns,DirIns,TelIns) VALUES(‘Recreando’,’Cra 3 Nro
2-44’,’8741522’);
INSERT INTO Institucion(NomIns,DirIns,TelIns) VALUES(‘Unidos por la
Cultura’,’Cra 2 Nro 2-22’,’8761623’);
GO
/*Datos para la tabla Tipo */
INSERT INTO Tipo(NomTipo) VALUES(‘Deporte Terrestre’);
INSERT INTO Tipo(NomTipo) VALUES(‘Deporte Acuático’);
INSERT INTO Tipo(NomTipo) VALUES(‘Deporte Aéreo’);
INSERT INTO Tipo(NomTipo) VALUES(‘Deporte Extremo’);
INSERT INTO Tipo(NomTipo) VALUES(‘Arte Contemporaneo’);
INSERT INTO Tipo(NomTipo) VALUES(‘Arte Rupestre’);
INSERT INTO Tipo(NomTipo) VALUES(‘Arte Moderno’);
INSERT INTO Tipo(NomTipo) VALUES(‘Música’);
INSERT INTO Tipo(NomTipo) VALUES(‘Peña Cultural’);
GO
/* Datos para la tabla Evento */
INSERT INTO Evento(NomEve,CodTipo,FechIni,FechFin) VALUES(‘Festival de la
canción’,9,’01/01/2012’,’02/01/2012’);
INSERT INTO Evento(NomEve,CodTipo,FechIni,FechFin) VALUES(‘Zonal de Fút-
bol’,1,’02/02/2012’,’02/03/2012’);
INSERT INTO Evento(NomEve,CodTipo,FechIni,FechFin) VALUES(‘Exposición de
Pintura’,5,’04/03/2012’,’11/03/2012’);
INSERT INTO Evento(NomEve,CodTipo,FechIni,FechFin) VALUES(‘Encuentro de
habilidades artísticas’,9,’11/04/2012’,’11/04/2012’);
INSERT INTO Evento(NomEve,CodTipo,FechIni,FechFin) VALUES(‘Concurso de
Rafting’,4,’04/15/2012’,’04/17/2012’);
GO
/* Datos para la tabla Institucion_Evento*/
INSERT INTO Institucion_Evento(CodEve,CodIns) Values(1,2);
INSERT INTO Institucion_Evento(CodEve,CodIns) Values(1,3);
INSERT INTO Institucion_Evento(CodEve,CodIns) Values(1,5);
INSERT INTO Institucion_Evento(CodEve,CodIns) Values(2,4);
INSERT INTO Institucion_Evento(CodEve,CodIns) Values(2,6);
INSERT INTO Institucion_Evento(CodEve,CodIns) Values(2,3);
INSERT INTO Institucion_Evento(CodEve,CodIns) Values(3,3);
INSERT INTO Institucion_Evento(CodEve,CodIns) Values(3,3);
INSERT INTO Institucion_Evento(CodEve,CodIns) Values(3,3);
INSERT INTO Institucion_Evento(CodEve,CodIns) Values(4,3);
INSERT INTO Institucion_Evento(CodEve,CodIns) Values(4,5);

4
FAVA - Formación en Ambientes Virtuales de Aprendizaje SENA - Servicio Nacional de Aprendizaje
Base de datos secretaria del medio ambiente - SQL SERVER

INSERT INTO Institucion_Evento(CodEve,CodIns) Values(4,1);


INSERT INTO Institucion_Evento(CodEve,CodIns) Values(5,2);
INSERT INTO Institucion_Evento(CodEve,CodIns) Values(5,1);
GO
/* Datos para la tabla Participante*/
INSERT INTO Participante(NomPar,ApePar,IdPar,EdadPar)
VALUES(‘Andres’,’Nieto Alvarez’,’83232390’,33);
INSERT INTO Participante(NomPar,ApePar,IdPar,EdadPar)
VALUES(‘Juan’,’Castro Nieto’,’83232392’,28);
INSERT INTO Participante(NomPar,ApePar,IdPar,EdadPar)
VALUES(‘Lunio’,’Castañeda Silva’,’80232393’,35);
INSERT INTO Participante(NomPar,ApePar,IdPar,EdadPar)
VALUES(‘Pedro’,’Nieto Alvarez’,’81232190’,24);
INSERT INTO Participante(NomPar,ApePar,IdPar,EdadPar)
VALUES(‘Daniel’,’Guzman Ortiz’,’84232397’,27);
INSERT INTO Participante(NomPar,ApePar,IdPar,EdadPar)
VALUES(‘Lino’,’Castro Ordoñez’,’82232391’,24);
INSERT INTO Participante(NomPar,ApePar,IdPar,EdadPar)
VALUES(‘Hernando’,’Moncaleano Vargas’,’83232244’,22);
INSERT INTO Participante(NomPar,ApePar,IdPar,EdadPar)
VALUES(‘Pablo’,’Henriquez Villa’,’81232396’,26);
INSERT INTO Participante(NomPar,ApePar,IdPar,EdadPar)
VALUES(‘Andres’,’Peña Silva’,’83234397’,27);
INSERT INTO Participante(NomPar,ApePar,IdPar,EdadPar)
VALUES(‘Adan’,’Perez Alvarez’,’83232333’,29);
INSERT INTO Participante(NomPar,ApePar,IdPar,EdadPar)
VALUES(‘Sergio’,’Nieto Vargas’,’84234394’,31);
INSERT INTO Participante(NomPar,ApePar,IdPar,EdadPar) VALUES(‘Jose
Miguel’,’Llanos Mosquera’,’83233398’,33);
INSERT INTO Participante(NomPar,ApePar,IdPar,EdadPar)
VALUES(‘Javier’,’Pinto Ortiz’,’82222390’,20);
INSERT INTO Participante(NomPar,ApePar,IdPar,EdadPar)
VALUES(‘Pedro’,’Castro Nieto’,’83232399’,25);
INSERT INTO Participante(NomPar,ApePar,IdPar,EdadPar)
VALUES(‘Manolo’,’Cardona Prieto’,’83232380’,23);
INSERT INTO Participante(NomPar,ApePar,IdPar,EdadPar)
VALUES(‘Luis’,’Carvajal Silva’,’83232395’,33);
INSERT INTO Participante(NomPar,ApePar,IdPar,EdadPar)
VALUES(‘Jairo’,’Osorio Castro’,’84232390’,37);
INSERT INTO Participante(NomPar,ApePar,IdPar,EdadPar)
VALUES(‘Leandro’,’Quintero Narvaez’,’83232330’,35);
INSERT INTO Participante(NomPar,ApePar,IdPar,EdadPar)
VALUES(‘Marcos’,’Dussan Alvarez’,’87237390’,31);
INSERT INTO Participante(NomPar,ApePar,IdPar,EdadPar)
VALUES(‘Diego’,’Polanco Vargas’,’88232398’,30);
INSERT INTO Participante(NomPar,ApePar,IdPar,EdadPar) VALUES(‘Julio’,’Neira

5
FAVA - Formación en Ambientes Virtuales de Aprendizaje SENA - Servicio Nacional de Aprendizaje
Base de datos secretaria del medio ambiente - SQL SERVER

Castro’,’82232290’,24);
INSERT INTO Participante(NomPar,ApePar,IdPar,EdadPar)
VALUES(‘Manuel’,’Silva Castro’,’84235390’,21);
INSERT INTO Participante(NomPar,ApePar,IdPar,EdadPar)
VALUES(‘Rafael’,’Mendieta Alvarez’,’83237397’,20);
INSERT INTO Participante(NomPar,ApePar,IdPar,EdadPar)
VALUES(‘Guillermo’,’Cano Soto’,’81232391’,19);
INSERT INTO Participante(NomPar,ApePar,IdPar,EdadPar)
VALUES(‘Pastor’,’Luna Ortiz’,’87238399’,22);
INSERT INTO Participante(NomPar,ApePar,IdPar,EdadPar)
VALUES(‘James’,’Claros Alvarez’,’81231391’,21);
INSERT INTO Participante(NomPar,ApePar,IdPar,EdadPar)
VALUES(‘Carlos’,’Alvarado Silva’,’84234395’,23);
INSERT INTO Participante(NomPar,ApePar,IdPar,EdadPar)
VALUES(‘Hernan’,’Rojas Alvarez’,’86236396’,23);
INSERT INTO Participante(NomPar,ApePar,IdPar,EdadPar)
VALUES(‘Jose’,’Martinez Rojas’,’84242390’,34);
INSERT INTO Participante(NomPar,ApePar,IdPar,EdadPar)
VALUES(‘Miguel’,’Silva Castro’,’88232390’,35);
INSERT INTO Participante(NomPar,ApePar,IdPar,EdadPar)
VALUES(‘Nelson’,’Gongora Muñoz’,’87237397’,37);
INSERT INTO Participante(NomPar,ApePar,IdPar,EdadPar)
VALUES(‘Fermín’,’Beltran Barragan’,’81232191’,39);
INSERT INTO Participante(NomPar,ApePar,IdPar,EdadPar)
VALUES(‘Francisco’,’Guarín Rojas’,’89239399’,40);
GO
/* Datos para la tabla Participante_Evento*/
INSERT INTO Participante_Evento(CodEve,CodPar,ValIns) VALUES(1,1,3000);
INSERT INTO Participante_Evento(CodEve,CodPar,ValIns) VALUES(1,2,3000);
INSERT INTO Participante_Evento(CodEve,CodPar,ValIns) VALUES(1,3,3000);
INSERT INTO Participante_Evento(CodEve,CodPar,ValIns) VALUES(1,4,3000);
INSERT INTO Participante_Evento(CodEve,CodPar,ValIns) VALUES(1,5,3000);
INSERT INTO Participante_Evento(CodEve,CodPar,ValIns) VALUES(1,6,3000);
INSERT INTO Participante_Evento(CodEve,CodPar,ValIns) VALUES(1,7,3000);
INSERT INTO Participante_Evento(CodEve,CodPar,ValIns) VALUES(1,8,3000);
INSERT INTO Participante_Evento(CodEve,CodPar,ValIns) VALUES(2,9,5000);
INSERT INTO Participante_Evento(CodEve,CodPar,ValIns) VALUES(2,10,5000);
INSERT INTO Participante_Evento(CodEve,CodPar,ValIns) VALUES(2,11,5000);
INSERT INTO Participante_Evento(CodEve,CodPar,ValIns) VALUES(2,12,5000);
INSERT INTO Participante_Evento(CodEve,CodPar,ValIns) VALUES(2,13,5000);
INSERT INTO Participante_Evento(CodEve,CodPar,ValIns) VALUES(2,14,5000);
INSERT INTO Participante_Evento(CodEve,CodPar,ValIns) VALUES(2,15,5000);
INSERT INTO Participante_Evento(CodEve,CodPar,ValIns) VALUES(3,16,6000);
INSERT INTO Participante_Evento(CodEve,CodPar,ValIns) VALUES(3,17,6000);
INSERT INTO Participante_Evento(CodEve,CodPar,ValIns) VALUES(3,18,6000);
INSERT INTO Participante_Evento(CodEve,CodPar,ValIns) VALUES(3,19,6000);

6
FAVA - Formación en Ambientes Virtuales de Aprendizaje SENA - Servicio Nacional de Aprendizaje
Base de datos secretaria del medio ambiente - SQL SERVER

INSERT INTO Participante_Evento(CodEve,CodPar,ValIns) VALUES(3,20,6000);


INSERT INTO Participante_Evento(CodEve,CodPar,ValIns) VALUES(3,21,6000);
INSERT INTO Participante_Evento(CodEve,CodPar,ValIns) VALUES(3,22,6000);
INSERT INTO Participante_Evento(CodEve,CodPar,ValIns) VALUES(3,23,6000);
INSERT INTO Participante_Evento(CodEve,CodPar,ValIns) VALUES(4,24,4500);
INSERT INTO Participante_Evento(CodEve,CodPar,ValIns) VALUES(4,25,4500);
INSERT INTO Participante_Evento(CodEve,CodPar,ValIns) VALUES(4,26,4500);
INSERT INTO Participante_Evento(CodEve,CodPar,ValIns) VALUES(4,27,4500);
INSERT INTO Participante_Evento(CodEve,CodPar,ValIns) VALUES(4,28,4500);
INSERT INTO Participante_Evento(CodEve,CodPar,ValIns) VALUES(4,29,4500);
INSERT INTO Participante_Evento(CodEve,CodPar,ValIns) VALUES(5,30,5500);
INSERT INTO Participante_Evento(CodEve,CodPar,ValIns) VALUES(5,12,5500);
INSERT INTO Participante_Evento(CodEve,CodPar,ValIns) VALUES(5,11,5500);
INSERT INTO Participante_Evento(CodEve,CodPar,ValIns) VALUES(5,10,5500);
INSERT INTO Participante_Evento(CodEve,CodPar,ValIns) VALUES(5,9,5500);
INSERT INTO Participante_Evento(CodEve,CodPar,ValIns) VALUES(5,7,5500);
INSERT INTO Participante_Evento(CodEve,CodPar,ValIns) VALUES(5,6,6500);
INSERT INTO Participante_Evento(CodEve,CodPar,ValIns) VALUES(5,5,6500);
GO

7
FAVA - Formación en Ambientes Virtuales de Aprendizaje SENA - Servicio Nacional de Aprendizaje
Oracle, Java, Oracle Logo, son marcas registradas
propiedades de Oracle. Copyright ©

PostgreSQL, PostgreSQL Logo, son marcas registradas


propiedades de PostgreSQL Global Development Group.
Copyright ©

Microsoft SQL Server, Microsoft SQL Server Logo, son marcas

Registered trademark
registradas propiedades de Microsoft. Copyright ©

Atribución, no comercial, compartir igual

Este material puede ser distribuido, copiado


y exhibido por terceros si se muestra en los
créditos. No se puede obtener ningún
ben rcial y las obras derivadas
tienen que estar bajo los mismos términos
de licencia que el trabajo original.

FAVA - Formación en Ambientes Virtuales de Aprendizaje SENA - Servicio Nacional de Aprendizaje

También podría gustarte