Create Database Escuela
Create Database Escuela
Create Database Escuela
USE ESCUELA;
CREATE TABLE ALUMNO(ID_ALUMNO int(4) not null primary key, NOMBREE varchar(50),
A_PATERNO varchar(50), A_MATERNO varchar(50), EDAD int(2));
CREATE TABLE MATERIA(id_materia int(2) not null primary key, nombre varchar(50), creditos
int(1), horas int(1));
CREATE TABLE PROFESOR(ID_PROFESOR int(4) not null primary key, NOMBREE varchar(50),
A_PATERNO varchar(50), A_MATERNO varchar(50), TITULO varchar(50));
CREATE TABLE ASIGNATURA(N_GRUPO int(3) not null primary key, MATERIA int(2), PROFESOR
int(4));
INSERT INTO ALUMNO VALUES(4215,'Pedro','Soto','Pérez',15);
INSERT INTO ALUMNO VALUES(3594,'Julieta','Robles','Valdivia',16);
INSERT INTO ALUMNO VALUES(8465,'plasd','asda','asd',0);
INSERT INTO ALUMNO VALUES(6548,'Alberto','Prado','Casares',20);
INSERT INTO ALUMNO VALUES(9563,'Kenia','Méndez','Flores',88);
INSERT INTO MATERIA VALUES(23,'Calculo',5,6);
INSERT INTO MATERIA VALUES(5,'Fisica',4,4);
INSERT INTO MATERIA VALUES(78,'Lójica',3,4);
INSERT INTO MATERIA VALUES(12,'Ética',3,3);
INSERT INTO PROFESOR VALUES(5485,'Miguel','Quintana','Madrid','Arquitectura');
INSERT INTO PROFESOR VALUES(9453,'Elizabeth','Jesus','Cuadrado','Filosofia');
INSERT INTO PROFESOR VALUES(1456,'Adolfo','Mayor','Cruz','Comunicación');
INSERT INTO PROFESOR VALUES(8569,'Sandra','Tapia','Torres','Química');
INSERT INTO ASIGNATURA VALUES(501,23,5485);
INSERT INTO ASIGNATURA VALUES(505,5,8569);
INSERT INTO ASIGNATURA VALUES(507,78,9453);
INSERT INTO ASIGNATURA VALUES(509,12,5485);
INSERT INTO ASIGNATURA VALUES(504,5,8569);
INSERT INTO ASIGNATURA VALUES(502,23,9453);
INSERT INTO ASIGNATURA VALUES(508,23,5485);
DELETE FROM ALUMNO
WHERE ID_ALUMNO=8465;
UPDATE ALUMNO
SET EDAD=16
WHERE ID_ALUMNO=9563;
UPDATE MATERIA
SET nombre='Lógica'
WHERE id_materia=78;
UPDATE ASIGNATURA
SET PROFESOR=9453
WHERE N_GRUPO=509;
DELETE FROM PROFESOR
WHERE ID_PROFESOR=1456;
UPDATE ASIGNATURA
SET MATERIA=78
WHERE N_GRUPO=502;
DELETE FROM ASIGNATURA
WHERE N_GRUPO=508;
DROP DATABASE ESCUELA;
CREATE DATABASE FERRETERIA_DB;
USE FERRETERIA_DB;
CREATE TABLE ARTICULOS(COD_ARTICULO int(4) not null primary key, DESC_ARTICULO
varchar(50), PRECIO_UNI int(3));
CREATE TABLE CLIENTE(ID_CLIENTE int(4) not null primary key, NOM_CLIENTE varchar(50),
ESTADO varchar(50), EMAIL varchar(100));
CREATE TABLE FACTURAS(ID_FACTURA int(5) not null primary key, FECHA date, ID_CLIENTE int(4),
foreign key(ID_CLIENTE) references CLIENTE(ID_CLIENTE));
CREATE TABLE DET_FACTURAS(N_REGISTRO int(1), ID_FACTURA int(5), COD_ARTICULO int(4),
CANTIDAD int(1), foreign key(ID_FACTURA) references FACTURAS(ID_FACTURA));
INSERT INTO ARTICULOS VALUES(1523,'MARTILLO',254);
INSERT INTO ARTICULOS VALUES(1485,'PEGAMENTO',35);
INSERT INTO ARTICULOS VALUES(1436,'CLAVOS',10);
INSERT INTO ARTICULOS VALUES(2147,'TORNILLOS',8);
INSERT INTO ARTICULOS VALUES(1563,'TUBO_PVC',130);
INSERT INTO CLIENTE VALUES(100,'JUAN CARLOS PÉREZ','VERACRUZ','[email protected]');
INSERT INTO CLIENTE VALUES(909,'FERRETERIA
FERNÁNDEZ','VERACRUZ','[email protected]');
INSERT INTO CLIENTE VALUES(250,'JAVIER GONZÁLEZ','SINALOA','[email protected]');
INSERT INTO CLIENTE VALUES(202,'MJEBLES
TRONCOZO','CDMX','[email protected]');
INSERT INTO CLIENTE VALUES(142,'HFKHF','KHFKH','[email protected]');
INSERT INTO FACTURAS VALUES(20080,2008-21-04,100);
INSERT INTO FACTURAS VALUES(20081,2008-22-04,909);
INSERT INTO FACTURAS VALUES(20082,2008-23-04,250);
INSERT INTO FACTURAS VALUES(20083,2008-23-04,250);
INSERT INTO DET_FACTURAS VALUES(1,20080,1523,1);
INSERT INTO DET_FACTURAS VALUES(2,20080,1485,1);
INSERT INTO DET_FACTURAS VALUES(3,20080,1436,3);
INSERT INTO DET_FACTURAS VALUES(4,20081,2147,5);
INSERT INTO DET_FACTURAS VALUES(5,20882,1563,1);
INSERT INTO DET_FACTURAS VALUES(6,20082,1485,2);
INSERT INTO DET_FACTURAS VALUES(7,20083,2147,8);
UPDATE CLIENTE
SET EMAIL='[email protected]'
WHERE ID_CLIENTE=250;
UPDATE DET_FACTURA
SET COD_ARTICULO=1563
WHERE N_REGISTRO=1;
UPDATE ARTICULOS
SET PRECIO_UNI=32
WHERE COD_ARTICULO=1485;
DELETE FROM CLIENTE
WHERE ID_CLIENTE=202;
DELETE FROM CLIENTE
WHERE ID_CLIENTE=142;
DROP DATABASE FERRETERIA_DB;