Sei sulla pagina 1di 9

Universidad Popular de Nicaragua Facultad de Informtica Sede Estel

Base de datos
Carrera:
Ingeniera en Computacin y Sistemas. 10-2101C

Ao:III
Grupo: Docente: Estudiantes: Roger Alizaga Omar Antonio Videa Tercero Erik Talavera

Fecha:02/06/2012

Clase Prctica.

1. Cree las tablas correspondientes. 2. Cree los procedimientos almacenados para cada una de las tablas, al menos los cuatro necesarios. 3. Cree las siguientes consultas. a) Mostrar los alumnos. b) Buscar un alumno. c) Mostrar los alumnos con notas mayores de 80.

Create table alumnos (n_carne int primary key not null, Nombre nvarchar (30) not null, apellido nvarchar (30) not null, direccion nvarchar (50) not null, telefono nvarchar (15) not null, cod_carrera int not null, cod_grupo int not null); create table notas (ncarne int primary key not null, Cod_materia int not null, Nota1 numeric (18) not null, Nota2 numeric (18) not null, Notaf numeric (18) not null, );

Create table materias (cod_materia int primary key not null, Material nvarchar (30) not null ); Create table carrera

(cod_carrera int primary key not null, Carrera nvarchar (30) not null ); Create table grupos (cod_grupo int primary key not null, Grupo int not null, N_aula int not null, N_tutor int not null ); Create table tutore (n_tutor int primary key not null, Tutor nvarchar (30)not null );

1. Cree los procedimientos almacenados para cada una de las tablas, al menos los cuatro necesarios. Procedimiento para la tabla alumnos a). Procedimiento de agregacin. Create Procedure Add_alumnos @ N_carnet int, @ Nombre nchar (30), @ Apellidos nchar (30, @ Direccin nchar (50), @Telefono nchar (15), @ Cod_Carrera int, @ Cod_Grupo int, As Begin Inset into alumnos @ N_carnet int; @ Nombre nchar (30), @ Apellidos nchar (30), @ Direccin nchar (50), @Telefono nchar (15), @ Cod_Carrera int, @ Cod_Grupo int, End; b). Procedimiento de actualizacin. Create Procedure Actualiza_alumnos @ N_carnet int,

@ Nombre nchar (30), @ Apellidos nchar (30, @ Direccin nchar (50), @Telefono nchar (15), @ Cod_Carrera int, @ Cod_Grupo int, As Begin Update alumnos Set N_carnet = @ N_carnet, Nombre = @ Nombre nchar (30), Apellidos = @ Apellidos nchar (30), Direccin = @ Direccin nchar (50), Telefono = @Telefono nchar (15), Cod_Carrera = @ Cod_Carrera int, Cod_Grupo = @ Cod_Grupo int, End; c). Procedimiento Delete. Create Procedure Delate Row alumnos @ N_carnet int, As Begin Delete From alumno where N_carnet = @ N_carnet, End; e). Procedimiento Mostrar. Create Procedure Mostar All alumnos As Begin Select * From alumno where N_carnet = @ N_carnet, End; N_carnet int Primary Key not null, Cod_Materia int not null, Nota1 numeric (18.0), Nota2 numeric (18.0), Nota3 numeric (18.0),) ; Procedimiento para la tabla Notas a). Procedimiento de agregacin. Create Procedure Add_notas @ Cod_Materia int, @ Nota1 numeric (18.0), @ Nota2 numeric (18.0), @ Nota3 numeric (18.0), As Begin Inset into notas @ Cod_Materia int, @ Nota1 numeric (18.0),

@ Nota2 numeric (18.0), @ Nota3 numeric (18.0), End; b). Procedimiento de actualizacin. Create Procedure Actualiza_notas @ Cod_Materia int, @ Nota1 numeric (18.0), @ Nota2 numeric (18.0), @ Nota3 numeric (18.0), As Begin Update notas Set Cod_Materia = @ Cod_Materia int, Nota1 = @ Nota1 numeric (18.0), Nota2 = @ Nota2 numeric (18.0), Nota3 = @ Nota3 numeric (18.0), End; c). Procedimiento Delete. Create Procedure Delate Row notas @ Cod_Materia int, As Begin Delete From nota where Cod_Materia = @ Cod_Materia, End; e). Procedimiento Mostrar. Create Procedure Mostar All notas As Begin Select * From notas where Cod_Materia = @ Cod_Materia, End; Procedimiento para la tabla Grupos a). Procedimiento de agregacin. Create Procedure Add_notas @ Cod_Carrera int, @ Grupo int, @ N_Aula int, @ N_Tutor int As Begin Inset into grupos @ Cod_Carrera int, @ Grupo int), @ N_Aula int, @ N_Tutor int, End;

b). Procedimiento de actualizacin. Create Procedure Actualiza_grupos @ Cod_Carrera int, @ Grupo int, @ N_Aula int, @ N_Tutor int, As Begin Update notas Set Cod_Carrera = @ Cod_Carrera int, Grupo = @ Grupo int, N_Aula = @ N_Aula int, N_Tutor = @ N_Tutor int, End; c). Procedimiento Delete. Create Procedure Delate Row gupos @ Cod_Carrera int, As Begin Delete From grupos where Cod_Carrera = @ Cod_Carrera, End; e). Procedimiento Mostrar. Create Procedure Mostar All grupos As Begin Select * From grupos where Cod_Carrera = @ Cod_Carrera, End; ; Procedimiento para la tabla Carreras a). Procedimiento de agregacin. Create Procedure Add_carreras @ Cod_Carrera int, @ Carrera nchar (30); As Begin Inset into carreras @ Cod_Carrera int, @ Carrera nchar (30) End;

b). Procedimiento de actualizacin. Create Procedure Actualiza_carreras @ Cod_Carrera int,

@ Carrera nchar(30), As Begin Update carreras Set Cod_Carrera = @ Cod_Carrera int, Carrera = @ Carrera nchar(30), End; c). Procedimiento Delete. Create Procedure Delate Row carreras @ Cod_Carrera int, As Begin Delete From grupos where Cod_Carrera = @ Cod_Carrera, End; e). Procedimiento Mostrar. Create Procedure Mostar All carreras As Begin Select * From carreras where Cod_Carrera = @ Cod_Carrera, End; Create Data Base Tutores Create table Tutores (N_Tutor int Primary Key not null, Tutor nchar (30) not null,) ; Procedimiento para la tabla Tutores a). Procedimiento de agregacin. Create Procedure Add_tutores @ N_Tutor int, @ Tutor nchar (30), As Begin Inset into tutores @ N_Tutor int, @ Tutor nchar (30), End; b). Procedimiento de actualizacin. Create Procedure Actualiza_tutores @ N_Tutor int, @ Tutor nchar (30), As Begin

Update tutores Set N_Tutor = @ N_Tutor int, Tutor = @ Tutor nchar(30), End; c). Procedimiento Delete. Create Procedure Delate Row Tutores @ N_Tutor int, As Begin Delete From tut where N_Tutor = @ N_Tutor, End; e). Procedimiento Mostrar. Create Procedure Mostar All tutores As Begin Select * From tutores where N_Tutor = @ N_Tutor, End; Procedimiento para la tabla Materias. a). Procedimiento de agregacin. Create Procedure Add_materias @ Cod_Materia int, @ Materia nchar (30), As Begin Inset into materias @ N_Tutor int, @ Tutor nchar (30), End; b). Procedimiento de actualizacin. Create Procedure Actualiza_materias @ Cod_Materia int, @ Materia nchar (30), As Begin Update materia Set Cod _materia = @ Cod_Materia int, materia = @ Materia nchar (30), End; c). Procedimiento Delete. Create Procedure Delate Row materia @ Cod_Materia int, As Begin Delete From materia where Cod_Materia = @ Cod_Materia,

End; e). Procedimiento Mostrar. Create Procedure Mostar All materia As Begin Select * From materia where Cod_Materia = @ Cod_Materia, End; 2. Cree las siguientes consultas. a) Mostrar los alumnos. b) Buscar un alumno. c) Mostrar los alumnos con notas mayores de 80. a). Mostrar los alumnos.

Mostrar todos los alumnos Seleet * from alumnos Buscar a un alumnos nombre Seleet * from alumnos where nombre = ? Mostrar alumnos con notas mayores a 80 Seleet nombre, apellido, notaf from alumnos, notas where alumnos.n_carne= notas. Ncarne And notas. Notaf >80

Potrebbero piacerti anche