PRACTICA 1
Taller Consultas relacionales
En la base de datos de la institucion 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:
Nota: tenga en cuenta que primero llena las tablas referenciales y posteriormente las relacionales.
Con la información de la base de datos de la Institución realizar las siguientes consultas:
1. Visualizar los estudiantes con sus acudientes:
Análisis:
1. Que desea consultar y de que tablas:
estudiante.codestu, estudiante.nombre, acudiente.codacu, acudiente.nombre.
2. Que tablas se ven afectadas o involucadas:
Acudiente, Estudiante, Acudiente_Estudiante
3. Identificar las condiciones si las hay: Que sea igual =
4. Como se relacionan las tablas:
estudiante.codestu = acudiente_estudiante.codestu and acudiente_estudiante.codacu = acudiente.codacu;
5. Que comando se debe utilizar:
select, where, and
Sintaxis:
select estudiante.codestu 'Cod. Estudiante' , estudiante.nombre 'Nombre Estudiante', acudiente.codacu 'Cod. Acudiente' , acudiente.nombre 'Nombre Acudiente' from estudiante, acudiente,acudiente_estudiante where estudiante.codestu = acudiente_estudiante.codestu and acudiente_estudiante.codacu = acudiente.codacu;
2. Que estudiantes no tienen acudiente asignado:
Análisis:
1. Que desea consultar y de que tablas:
estudiante.codestu, estudiante.nombre, acudiente.codacu, acudiente.nombre.
2. Que tablas se ven afectadas o involucadas:
Acudiente, Estudiante, Acudiente_Estudiante
3. Identificar las condiciones si las hay: left join, on
4. Como se relacionan las tablas:
acudiente_estudiante.codestu=estudiante.codestu where acudiente_estudiante.codestu is null;
5. Que comando se debe utilizar:
select, where
Sintaxis:
select estudiante.codestu'Cod. Estudiante', estudiante.nombre 'Nombre Estudiante' from estudiante left join acudiente_estudiante on acudiente_estudiante.codestu=estudiante.codestu where acudiente_estudiante.codestu is null;
3. Que acudientes no matricularon sus hijos en la institución:
Análisis:
1. Que desea consultar y de que tablas:
acudiente.codacu, acudiente.nombre,estudiante.codacu.
2. Que tablas se ven afectadas o involucadas:
Acudiente, Estudiante, Acudiente_Estudiante
3. Identificar las condiciones si las hay: left join, on
4. Como se relacionan las tablas:
acudiente_estudiante.codestu=estudiante.codestu where acudiente_estudiante.codestu
acudiente_estudiante.codacu is null;
5. Que comando se debe utilizar:
select, where
Sintaxis:
select acudiente.codacu'Cod. Acudiente', acudiente.nombre 'Nombre Acudiente' from acudiente left join acudiente_estudiante on acudiente_estudiante.codacu=acudiente.codacu where acudiente_estudiante.codacu is null;
Análisis:
1. Que desea consultar y de que tablas:
materia.codmat, materia.nombre,estudiante.codestu
2. Que tablas se ven afectadas o involucadas:
Materia, Estudiante, estudiante_materia
3. Identificar las condiciones si las hay:
estudiante.codestu = '00001'
4. Como se relacionan las tablas:
estudiante.codestu = estudiante_materia.codestu and estudiante_materia.codmat=materia.codmat;
5. Que comando se debe utilizar:
select, where, and
Sintaxis:
select materia.codmat 'Cod. Materia', materia.nombre 'Nombre materia' from estudiante, materia, estudiante_materia where estudiante.codestu = '00001' and estudiante.codestu = estudiante_materia.codestu and estudiante_materia.codmat=materia.codmat;
5. Visualizar los estudiantes con las materias que matricularon:
Análisis:
1. Que desea consultar y de que tablas:
estudiante.codestu ,estudiante.nombre, materia.codmat, materia.nombre
2. Que tablas se ven afectadas o involucadas:
Materia, Estudiante, estudiante_materia
3. Identificar las condiciones si las hay: N/A
4. Como se relacionan las tablas:
estudiante.codestu = estudiante_materia.codestu and estudiante_materia.codmat = materia.codmat
5. Que comando se debe utilizar:
select, where, and
Sintaxis:
select estudiante.codestu 'Cod. Estudiante' , estudiante.nombre 'Nom. Estudiante', materia.codmat 'Cod. Materia' , materia.nombre 'Nom. Materia' from estudiante, materia, estudiante_materia where estudiante.codestu = estudiante_materia.codestu and estudiante_materia.codmat = materia.codmat;
Análisis:
1. Que desea consultar y de que tablas:
estudiante.codestu , estudiante.nombre, materia.codestu
2. Que tablas se ven afectadas o involucadas:
Materia, Estudiante, estudiante_materia
3. Identificar las condiciones si las hay: left join, on
4. Como se relacionan las tablas:
estudiante_materia.codestu=estudiante.codestu,
estudiante_materia.codestu is null;
5. Que comando se debe utilizar:
select, where
Sintaxis:
select estudiante.codestu'Cod. Estudiante', estudiante.nombre 'Nombre Estudiante' from estudiante left join estudiante_materia on estudiante_materia.codestu=estudiante.codestu where estudiante_materia.codestu is null;
7. Visualizar un listado de las materias a las que ningún estudiante se matriculó:
Análisis:
1. Que desea consultar y de que tablas:
materia.codmat , materia.nombre,
2. Que tablas se ven afectadas o involucadas:
Materia, Estudiante, estudiante_materia
3. Identificar las condiciones si las hay: left join, on
4. Como se relacionan las tablas:
estudiante_materia.codmat=materia.codmat,
estudiante_materia.codmat is null;
5. Que comando se debe utilizar:
select, where
Sintaxis:
select materia.codmat'Cod. Materia', materia.nombre'Nombre Materia' from materia left join estudiante_materia on estudiante_materia.codmat=materia.codmat where estudiante_materia.codmat is null;
8. Visualizar los docentes con las materias que dictan:
Análisis:
1. Que desea consultar y de que tablas:
profesor.codprof, profesor.nombre, materia.codmat, materia.nombre, profesor.codmat
2. Que tablas se ven afectadas o involucadas:
Materia, Profesor, materia_profesor
3. Identificar las condiciones si las hay: N/A
4. Como se relacionan las tablas:
profesor.codprof=materia_profesor.codprof and materia.codmat=materia_profesor.codmat
5. Que comando se debe utilizar:
select, where, and
Sintaxis:
select profesor.codprof'Cod. Profesor', profesor.nombre'Nombre profesor', materia.codmat'Cod. Materia', materia.nombre'Nombre Materia' from profesor, materia, materia_profesor where profesor.codprof=materia_profesor.codprof and materia.codmat=materia_profesor.codmat;
9. Visualizar las materias que no tienen docente asignado.
Análisis:
1. Que desea consultar y de que tablas:
materia.codmat, materia.nombre, profesor.codmat
2. Que tablas se ven afectadas o involucadas:
Materia, Profesor, materia_profesor
3. Identificar las condiciones si las hay: left join, on
4. Como se relacionan las tablas:
materia_profesor.codmat=materia.codmat,
materia_profesor.codmat is null;
5. Que comando se debe utilizar:
select, where
Sintaxis:
select materia.codmat'Cod. Materia', materia.nombre'Nombre Materia' from materia left join materia_profesor on materia_profesor.codmat=materia.codmat where materia_profesor.codmat is null;
10. Visualizar que docentes no tienen materias asignadas:
Análisis:
1. Que desea consultar y de que tablas:
profesor.codprof, profesor.nombre,
2. Que tablas se ven afectadas o involucadas:
Materia, Profesor, materia_profesor
3. Identificar las condiciones si las hay: left join, on
4. Como se relacionan las tablas:
materia_profesor.codprof=profesor.codprof,
materia_profesor.codprof is null;
5. Que comando se debe utilizar:
select, where
Sintaxis:
select profesor.codprof'Cod. Profesor', profesor.nombre'Nombre Profesor' from profesor left join materia_profesor on materia_profesor.codprof=profesor.codprof where materia_profesor.codprof is null;
11. Visualizar el estudiante con las materias que tiene matriculadas y que docentes las dicta:
Análisis:
1. Que desea consultar y de que tablas:
estudiante.codestu, estudiante.nombre, materia.codmat, materia.nombre, profesor.codprof, profesor.nombre,
2. Que tablas se ven afectadas o involucadas:
Materia, Profesor, estmatprof
3. Identificar las condiciones si las hay: N/A
4. Como se relacionan las tablas:
estudiante.codestu=estmatprof.codestu and estmatprof.codmat=materia.codmat and profesor.codprof=estmatprof.codprof
5. Que comando se debe utilizar:
select, where, distinct, and
Sintaxis:
select distinct estudiante.codestu'Cod. Estudiante', estudiante.nombre'Nombre Estudiante',materia.codmat'Cod. Materia',materia.nombre'Nombre Materia', profesor.codprof'Cod. Profesor',profesor.nombre'Nombre Profesor' from estudiante,materia,profesor,estmatprof where estudiante.codestu=estmatprof.codestu and estmatprof.codmat=materia.codmat and profesor.codprof=estmatprof.codprof;
El siguiente es el archivo de Modelo_Entidad_Relacion, Diagrama_Relacional y Datos
El siguiente es el archivo de las evidencias del la Practica 1 txt
El siguiente es el archivo de la base de datos Institucion

