Taller Consultas relacionales
En la base de datos de la institución insertarle los datos que se encuentran en el siguiente archivo de excel (crear las tablas que no se encuentre en la base de datos) y dibujar el nuevo modelo entidad relación y el diagrama relacional:
Con la información de la base de datos de la Institución realizar las siguientes consultas:
1. Visualizar los estudiantes con sus acudientes
- Que se desea consultar
Cada estudiante con su acudiente
estudiante.Idest,estudiante.Nombre,acudiente.Nombre
a) select estudiante.Idest, estudiante.Nombre,acudiente.Nombre from estudiante,acudiente,est_acud where estudiante.Idest=est_acud.Idest and est_acud.Idacud=acudiente.Idacud;
estudiante.Idest,estudiante.Nombre,acudiente.Nombre
- Que tablas se ven afectadas o involucradas
- Condición:
- Como se relacionan las tablas
estudiante.Idest=est_acud.Idest est_acud.Idacud=acudiente.Idacud
- Que comando se debe utilizar
a) select estudiante.Idest, estudiante.Nombre,acudiente.Nombre from estudiante,acudiente,est_acud where estudiante.Idest=est_acud.Idest and est_acud.Idacud=acudiente.Idacud;
2. Que estudiantes no tienen acudiente asignado
- Que se desea consultar
Estudiantes que no tienen acudiente
estudiante.Idest, estudiante.Nombre
- Que tablas se ven afectadas o involucradas
- Condición:
Idest=null
- Como se relacionan las tablas
estudiante.Idest=est_acud.Idest
- Que comando se debe utilizar
a) select estudiante.Idest, estudiante.Nombre from estudiante,est_acud where est_acud.Idest=null;
3. Que acudientes no matricularon sus hijos en la institución
- Que se desea consultar
Acudientes que no tienen hijos en la escuela
acudiente.Idacud, acudiente.Nombre
- Que tablas se ven afectadas o involucradas
- Condición:
Idacud=null
- Como se relacionan las tablas
acudiente.Idacud=est_acud.Idacud
- Que comando se debe utilizar
a) select acudiente.Idacud, acudiente.Nombre from acudiente,est_acud where est_acud.Idacud=null;
b)select acudiente.Idacud, acudiente.Nombre from acudiente left join est_acud on acudiente.Idacud=est_acud.Idacud where est_acud.Idacud is null;
4.Visualizar las materias que matriculó el estudiante 00001
- Que se desea consultar
Materias matriculadas por el estudiante 00001
estudiante.Idest,estudiante.nombre,materia.nombre
- Que tablas se ven afectadas o involucradas
- Condición:
De la tabla est_mat Idest=00001
- Como se relacionan las tablas
estudiante.Idest=est_mat.Idest
- Que comando se debe utilizar
b) select distinct estudiante.Idest,estudiante.Nombre,materia.Nombre from estudiante inner join est_mat on estudiante.Idest=est_mat.Idest inner join materia on est_mat.Idest='00001';
5. Visualizar los estudiantes con las materias que matricularon
- Que se desea consultar
Estudiantes con materias que matricularon
estudiante.Idest,estudiante.Nombre,materia.Nombre
- Que tablas se ven afectadas o involucradas
- Condición:
Ninguna
- Como se relacionan las tablas
estudiante.Idest=est_mat.Idest
est_mat.Idmat=materia.Idmat;
est_mat.Idmat=materia.Idmat;
- Que comando se debe utilizar
a) select estudiante.Idest,estudiante.Nombre,materia.Nombre from estudiante, materia, est_mat where estudiante.Idest=est_mat.Idest and est_mat.Idmat=materia.Idmat;
b) select distinct estudiante.Idest,estudiante.Nombre,materia.Nombre from estudiante inner join est_mat on estudiante.Idest=est_mat.Idest inner join materia on est_mat.Idmat=materia.Idmat;
6. Visualizar un listado de los estudiantes que no se han matriculado
- Que se desea consultar
Estudiantes que no se matricularon
estudiante.Idest, estudiante.Nombre
- Que tablas se ven afectadas o involucradas
- Condición:
De la tabla est_mat Idest=null
- Como se relacionan las tablas
estudiante.Idest=est_mat.Idest
- Que comando se debe utilizar
a) select estudiante.Idest, estudiante.Nombre from estudiante,materia,est_mat where estudiante.Idest=est_mat.Idest and est_mat.Idmat=materia.Idmat and est_mat.Idest=null;
b)select estudiante.Idest, estudiante.Nombre from estudiante left join est_mat on estudiante.Idest=est_mat.Idest where est_mat.Idest is null;
7. Visualizar un listado de las materias a las que ningún estudiante se matriculó.
- Que se desea consultar
Materias que ningún estudiante matriculo
materia.Idmat, materia.Nombre
- Que tablas se ven afectadas o involucradas
- Condición:
Idmat=null
- Como se relacionan las tablas
materia.Idmat=est_mat.Idmat
- Que comando se debe utilizar
a) select materia.Idmat, materia.Nombre from materia, est_mat where est_mat.Idmat=null;
b)select materia.Idmat, materia.Nombre from materia left join est_mat on materia.Idmat=est_mat.Idmat where est_mat.Idmat is null;
8. Visualizar los docentes con las materias que dictan
- Que se desea consultar
- Cada docente con la materia que dicta
- Que tablas se ven afectadas o involucradas
Profesor, materia, mat_prof
- Condición:
Ninguna
- Como se relacionan las tablas
profesor.Idprof=mat_prof.Idprof mat_prof.Idmat=materia.Idmat
- Que comando se debe utilizar
a) select profesor.Idprof, profesor.Nombre,materia.Nombre from profesor,materia,mat_prof where profesor.Idprof=mat_prof.Idprof and mat_prof.Idmat=materia.Idmat;
9. Visualizar las materias que no tienen docente asignado.
- Que se desea consultar
- Materia que no tienen docente asignado
materia.Idmat, materia.Nombre
- Que tablas se ven afectadas o involucradas
Materia, profesor, mat_prof
- Condición:
Idprof=null
- Como se relacionan las tablas
materia.Idmat=mat_prof.Idmat
- Que comando se debe utilizar
a) select materia.Idmat, materia.Nombre from materia,profesor,mat_prof where mat_prof.Idprof=null;
b)select materia.Idmat,materia.Nombre from materia left join mat_prof on materia.Idmat=mat_prof.Idmat where mat_prof.Idprof is null;
10. Visualizar que docentes no tienen materias asignadas.
- Que se desea consultar
- Docentes que no tienen materias asignadas
- profesor.Idprof, profesor.Nombre
- Que tablas se ven afectadas o involucradas
Profesor y mat_prof
- Condición:
Idprof=null
- Como se relacionan las tablas
profesor.Idprof=mat_prof.Idprof
- Que comando se debe utilizar
a) select profesor.Idprof, profesor.Nombre from profesor, mat_prof where mat_prof.Idprof=null;
b)select profesor.Idprof, profesor.Nombre from profesor left join mat_prof on profesor.Idprof=mat_prof.Idprof where mat_prof.Idprof is null;
11. Visualizar el estudiante con las materias que tiene matriculadas y que docentes las dicta.
- Que se desea consultar
Estudiantes con sus materias y los profesores que las dictan
estudiante.Idest, estudiante.Nombre,materia.Nombre,mat_prof.Idprof.Nombre
- Que tablas se ven afectadas o involucradas
Estudiante, materia,profesor,est_mat,mat_prof
- Condición:
Ninguna
- Como se relacionan las tablas
estudiante.Idest=est_mat.Idest est_mat.Idmat=materia.Idmat
mat_prof.Idprof=profesor.Idprof;
mat_prof.Idprof=profesor.Idprof;
- Que comando se debe utilizar
a) select estudiante.Idest, estudiante.Nombre,materia.Nombre,mat_prof.Idprof.Nombre from estudiante,materia,est_mat where estudiante.Idest=est_mat.Idest and mat_prof.Idmat=materia.Idmat;