6
Que entregue los estudiantes que son de Ing. Comercial (NOMBRES y APELLIDOS del estudiante, NOMBRE de la carrera y NOMBRE del campus). select e.NOMBRES, e.APELLIDOS, c.NOMBRE, c.ID_CAMPUS from CARRERAS c, ESTUDIANTES e where e.ID_CARRERA = c.ID_CARRERA and c.ID_CARRERA = 2 Que entregue los estudiantes que son de Auditoria (NOMBRES y APELLIDOS del estudiante, NOMBRE de la carrera y NOMBRE del campus). select e.NOMBRES, e.APELLIDOS, c.NOMBRE, c.ID_CAMPUS from CARRERAS c, ESTUDIANTES e where e.ID_CARRERA = c.ID_CARRERA and c.ID_CARRERA = 1 c) Que entregue los estudiantes que se atrasaron en la entrega de los libros (RUT, NOMBRES, APELLIDOS y FONO). select e.NOMBRES, e.APELLIDOS, P.Rut_Est, e.FONO from PRESTAMO P, ESTUDIANTES e where P.RUT_EST = e.RUT_EST and P.Fecha_e > P.Fecha_p d) La cantidad de libros prestados. select count (*) from PRESTAMO e) Los libros de editoriales extranjeras (CODIGO, TITULO , AÑO y PAIS de ORIGEN). select l.COD_LIBRO, l.TITULO, l.AGNO AS AÑO, ed.ID_EDIT, ed.PAIS from LIBROS l, EDITORIALES ed where ed.id_edit = l.id_edit and ed.PAIS < > 'CHILE'

Tarea sia 30-04-12

Embed Size (px)

Citation preview

Page 1: Tarea sia 30-04-12

Que entregue los estudiantes que son de Ing. Comercial (NOMBRES y APELLIDOS del estudiante, NOMBRE de la carrera y NOMBRE del campus).

select e.NOMBRES, e.APELLIDOS, c.NOMBRE, c.ID_CAMPUSfrom CARRERAS c, ESTUDIANTES ewhere e.ID_CARRERA = c.ID_CARRERAand c.ID_CARRERA = 2

Que entregue los estudiantes que son de Auditoria (NOMBRES y APELLIDOS del estudiante, NOMBRE de la carrera y NOMBRE del campus).

select e.NOMBRES, e.APELLIDOS, c.NOMBRE, c.ID_CAMPUSfrom CARRERAS c, ESTUDIANTES ewhere e.ID_CARRERA = c.ID_CARRERAand c.ID_CARRERA = 1

c) Que entregue los estudiantes que se atrasaron en la entrega de los libros (RUT, NOMBRES, APELLIDOS y FONO). select e.NOMBRES, e.APELLIDOS, P.Rut_Est, e.FONOfrom PRESTAMO P, ESTUDIANTES ewhere P.RUT_EST = e.RUT_ESTand P.Fecha_e > P.Fecha_p

d) La cantidad de libros prestados.

select count(*)from PRESTAMO

e) Los libros de editoriales extranjeras (CODIGO, TITULO , AÑO y PAIS de ORIGEN).

select l.COD_LIBRO, l.TITULO, l.AGNO AS AÑO, ed.ID_EDIT, ed.PAISfrom LIBROS l, EDITORIALES edwhere ed.id_edit = l.id_editand ed.PAIS < > 'CHILE'

f) Los libros que son de reserva (CODIGO, TITULO y AÑO del LIBRO, NOMBRE de la biblioteca, el NOMBRE y APELLIDO del autor, el NOMBRE de la editorial y el PAIS ).

select l.COD_LIBRO, l.TITULO, l.AGNO AS AÑO, b.BIBLIOTECA, au.NOMBRES, au.APELLIDOS, ed.NOMBRE, ed.PAISfrom BIBLIOTECA b, EDITORIALES ed, AUTORES au, LIBROS l, TIPO twhere t.TIPO_P = 'RESERVA'

Page 2: Tarea sia 30-04-12

2.-Se requiere obtener datos desde la Base de Datos y almacenarlos de forma permanente (Vista). Se solicita: Los estudiantes del campus Isla Teja, que tienen libros en su poder (atrasados o no).

CREATE VIEW data_estudiantesAS(select e.rut_est, e.nombres as est, e.apellidos as est_2, e.fono as fon_est, p.fecha_efrom estudiantes e, prestamo pwhere e.rut_est=p.rut_est and p.fecha_e<sysdate

Se debe entregar el RUT, NOMBRE y APELLIDOS del estudiante, además del NOMBRE de la carrera a la cual pertenece.

CREATE VIEW LIST_EST_C.TEJAAS(SELECT e.NOMBRES, e.APELLIDOS, p.RUT_EST, c.NOMBREFROM ESTUDIANTES e, PRESTAMO p, CAMPUS cWHERE p.Rut_Est = e.RUT_ESTAND C.NOMBRE = 'ISLA TEJA')

Para ver consulta ejecutar comando

select *from EST_TEJA_CLIBROS

Además se debe entregar que libro tiene prestado, indicando CODIGO, TITULO y AÑO, el NOMBRE y APELLIDO del autor, la EDITORIAL y su PAIS, indicar en qué Biblioteca se encuentra, y de qué tipo es.

CREATE VIEW EST_TEJA_CLIBROSAS(Select E.RUT_EST,E.NOMBRES,E.APELLIDOS,C.NOMBRE,L.COD_LIBRO,L.TITULO,L.AGNO,A.NOMBRES,A.APELLIDOS,ED.NOMBRE,ED.PAIS,B.BIBLIOTECA,T.TIPO_Pfrom ESTUDIANTES E, CARRERAS C,LIBROS L,AUTORES A,EDITORIALES ED,BIBLIOTECA B,TIPO T)

Page 3: Tarea sia 30-04-12

Se debe indicar que funcionario realizo la transacción, con RUT, NOMBRE y APELLIDO.

CREATE VIEW data_relacion_func_prestamoAS(select e.rut_est, e.nombres as estudiante, e.apellidos, c.nombre as carrera, l.cod_libro, l.titulo, l.agno, a.nombres as autor, a.apellidos as ape_autor, ed.nombre as edit, ed.pais, b.biblioteca, t.tipo_p, f.rut_func, f.nombres as funcionario, f.apellidos as ape_funciofrom estudiantes e, carreras c, libros l, autores a, editoriales ed, biblioteca b, tipo t, prestamo p, funcionarios fwhere e.id_carrera = c.id_carreraand e.rut_est = p.rut_estand l.cod_libro = p.cod_libroand l.rut_autor = a.rut_autorand l.id_edit = ed.id_editand l.id_biblio = b.id_biblioand l.id_tipo = t.id_tipoand f.rut_func = p.rut_func)

Además deberá indicarse la FECHA de PRESTAMO y la FECHA de ENTREGA de éste.NOTA: deberá añadir ALIAS al NOMBRE del estudiante, del funcionario, del autor y de la carrera para diferenciarlos.

CREATE VIEW data_relacion_funcionario_prestamo_fecha_P_EAS(select e.rut_est, e.nombres as estudiante, e.apellidos, c.nombre as carrera, l.cod_libro, l.titulo, l.agno, a.nombres as autor, a.apellidos as ape_autor, ed.nombre as edit, ed.pais, b.biblioteca, t.tipo_p, f.rut_func, f.nombres as funcionario, f.apellidos as ape_funcio, p.fecha_p as prest_fecha, p.fecha_e as entregafrom estudiantes e, carreras c, libros l, autores a, editoriales ed, biblioteca b, tipo t, prestamo p, funcionarios fwhere e.id_carrera = c.id_carreraand e.rut_est = p.rut_estand l.cod_libro = p.cod_libroand l.rut_autor = a.rut_autorand l.id_edit = ed.id_editand l.id_biblio = b.id_biblioand l.id_tipo = t.id_tipoand f.rut_func = p.rut_func)

Page 4: Tarea sia 30-04-12

3.- Se solicita obtener lo siguiente (consultas):

a) El numero de Estudiantes por Carrera.

select ci.id_ciudad, count(e.rut_est) from estudiantes e, ciudad ci group by ci.id_ciudad

b) El numero de Estudiantes por Campus

select cc.id_campus, count(e.rut_est) from estudiantes e, campus cc group by cc.id_campus

c) El numero de Estudiantes por Ciudad

select ci.id_ciudad, count(e.rut_est) from estudiantes e, ciudad ci group by ci.id_ciudad

d) El numero de Préstamos atrasados

select fecha_e, count(fecha_p) from prestamo group by fecha_e having fecha_e<sysdate

e) El número de Prestamos Activos, No atrasados.

select fecha_e, count(fecha_p) from prestamo group by fecha_e having fecha_e>sysdate