Está en la página 1de 4

Base de datos

APRENDIZ:

Michael David Argotti Zúñiga

INSTRUCTOR:

Andrea Palomino Salcedo

ADSI 61

SANTIAGO DE CALI

2014
Create database colegio;

Use colegio;

Create table curso (idcurso char (4) NOT NULL, nomcurso varchar (40) NOT NULL, vacantes
numeric (2) NOT NULL, matriculados numeric (2) NOT NULL, professor varchar (40), precursor
numeric (8) NOT NULL);

Create table matricula (idcurso char (4) NOT NULL, idalumno numeric (5) NOT NULL, fecha date
NOT NULL, precio numeric (8) NOT NULL, cuotas numeric (2) NOT NULL, nota numeric (4));

Create table alumno (idalumno numeric (5) NOT NULL, nomalumno varchar (40) NOT NULL,
dirección varchar (40) NOT NULL, teléfono varchar (15));

Create table pago (idcurso char (4) NOT NULL, idalumno numeric (5) NOT NULL, cuota numeric (5)
NOT NULL, fecha date NOT NULL, importe numeric (8) NOT NULL);

Insert into alumno (idalumno, nomalumno, direccion, telefono) values ('789','stevens','kra7 N 43-
6',3446780);

Insert into alumno (idalumno, nomalumno, direccion, telefono) values ('5678','david','kra7 N


67',4411919);

Insert into alumno (idalumno, nomalumno, direccion, telefono) values ('5567','maicol','call 8b con
34C',445683);

Insert into alumno (idalumno, nomalumno, direccion, telefono) values ('34567','leydi','call 10 con
42bn19',4532114);

Insert into alumno (idalumno, nomalumno, direccion, telefono) values ('56411','julian','kra 4 sur #
12 bn 43',3331245);

Insert into curso (idcurso, nomcurso, vacantes, matriculados, profesor, precurso) values
('4356','electricidad',10, 10,'julian',4);

Insert into curso (idcurso, nomcurso, vacantes, matriculados, profesor, precurso) values
('5467','quimica',30, 15,'yormit',9);

Insert into curso (idcurso, nomcurso, vacantes, matriculados, profesor, precurso) values
('6790','ingles',20, 12,'tascon',5);

Insert into curso (idcurso, nomcurso, vacantes, matriculados, profesor, precurso) values
('7333','diseño',45, 29,'ricardo',12);

Insert into curso (idcurso, nomcurso, vacantes, matriculados, profesor, precurso) values
('6512','mecanica',64, 55,'ceballos',15);
Insert into matricula (idcurso, idalumno, fecha, precio, cuotas, nota) values ('3457','5690','2014-
08-01', 460000,4, 3);

Insert into matricula (idcurso, idalumno, fecha, precio, cuotas, nota) values ('4578','1223','2004-
11-23', 300500,3, 5);

Insert into matricula (idcurso, idalumno, fecha, precio, cuotas, nota) values ('6780','56709','2010-
02-15', 15030620,7, 4);

Insert into matricula (idcurso, idalumno, fecha, precio, cuotas, nota) values ('4012','78903','2001-
06-31', 800500,4, 2);

Insert into matricula (idcurso, idalumno, fecha, precio, cuotas, nota) values ('5413','09532','2005-
10-15', 20500400,8, 5);

Insert into pago (idcurso, idalumno, cuota, fecha, importe) values ('6258','11489', 19,'2007-6-
25',36005250);

Insert into pago (idcurso, idalumno, cuota, fecha, importe) values ('9834','11580', 25,'2010-12-
10',10635000);

Insert into pago (idcurso, idalumno, cuota, fecha, importe) values ('6475','22457', 15,'2001-3-
15',3096840);

Insert into pago (idcurso, idalumno, cuota, fecha, importe) values ('1145','79635', 10,'2003-1-
19',4569307);

Insert into pago (idcurso, idalumno, cuota, fecha, importe) values ('7968','36985', 9,'2011-7-
9',45693750);

use colegio;

alter table curso add primary key (idcurso);

use colegio;

alter table alumno add primary key (idalumno);

alter table matricula add foreign key (idcurso) references curso (idcurso);

alter table matricula add foreign key (idalumno) references alumno (idalumno);

 Drop database ejercicio;


 use ejercicio;
Drop table personas;

Create database bnbb;

Use bnbb;

Create table material (idcurso char (4) NOT NULL, nomcurso varchar (40) NOT NULL, vacantes
numeric (2) NOT NULL, matriculados numeric (2) NOT NULL, professor varchar (40), precursor
numeric (8) NOT NULL);

Alter table personal add (mascota char (30), pasatiempo char (20) not null);

También podría gustarte