jueves, 18 de enero de 2018

CONSULTAS SQL


Principales sentencias SQL que se debe aplicar a la base de datos Cole.

1. /*Alumnos que tengan 15 años*/
select alumno.nombre, alumno.apellido
from alumno
where alumno.edad=15;

2. /*Edad del Alumno Perez*/
select alumno.edad
from alumno
where alumno.apellido='PEREZ';

3. /*Primera nota de todos los Alumno*/
select alumno.nombre, nota.nota1
from alumno, nota
where nota.alumno_idalumno = alumno.idalumno ;

4. /*Primera nota de todos los Alumno por materia*/
select alumno.nombre, nota.nota1, materia.nombre
from alumno, nota, materia
where nota.alumno_idalumno = alumno.idalumno and nota.alumno_materia_idmateria = materia.idmateria;


5. /*Alumnos por materias*/
select alumno.nombre, alumno.apellido, materia.nombre
from alumno, materia
where materia.idmateria = alumno.materia_idmateria and materia.nombre = 'MFP'
order by alumno.apellido;

6. /*Notas por materias*/
select alumno.nombre, alumno.apellido, materia.nombre, nota.nota1, nota2
from alumno, materia, nota
where  materia.idmateria = alumno.materia_idmateria and materia.nombre = 'MFP'
group by alumno.nombre;

7. /*Profesor por materias*/
select profesor.nombre, profesor.apellido, materia.nombre
from profesor, materia
where materia.profesor_idprofesor = profesor.idprofesor
order by profesor.nombre;

8. /*Primera nota de todos los Alumno por materia*/
select alumno.nombre, nota.nota1, materia.nombre
from alumno, nota, materia
where nota.alumno_idalumno = alumno.idalumno and nota.alumno_materia_idmateria = materia.idmateria;

TEMARIOS PARA EL APORTE
1.     Modelo Entidad Relación (MER)
2.     Claves: Primarias, Alternativas, Foráneas.
3.     Entidades
4.     Atributos
5.     Relaciones
6.     MySql
7.     Comandos DDL – DML
8.     Cláusulas
9.     Operadores

10.  Consultas en MySql