create database colegio;
create table profesor(
doc_prof varchar(30) not null,
nom_prof varchar(30) not null,
ape_prof varchar(30) not null,
cate_prof int not null,
sal_prof int not null,
primary key (doc_prof)
);
create table curso(
cod_curs int auto_increment not null,
nom_cur varchar(100) not null,
horas_cur int not null,
valor_cur int not null,
doc_curs_prof varchar(30) not null,
primary key(cod_curs),
foreign key (doc_curs_prof) references profesor(doc_prof)
);
create table Estudiante(
doc_est varchar(30) not null,
nom_est varchar(30) not null,
ape_est varchar(30) not null,
edad_est int not null,
primary key (doc_est)
);
create table estudianteCurso(
cod_cur_estcur int(11) not null,
doc_est_estcur varchar(11) not null,
fec_ini_estcur date not null,
foreign key(cod_cur_estcur) references curso(cod_curs),
foreign key(doc_est_estcur) references Estudiante(doc_est)
);
insert into profesor () values ("63.502.720", "Martha", "Rojas", 2, 690000);
insert into profesor () values("91.216.904", "Carlos", "Pérez", 3 , 950000);
insert into profesor () values("13.826.789", "Maritza", "Angarita" , 1 ,550000);
insert into profesor () values("[Link]", "Alejandra", "Torres" , 4 ,
1100000);
insert into curso (
cod_curs,
nom_cur,
horas_cur,
valor_cur,
doc_curs_prof ) values(
149842,"Fundamentos de bases de datos", 40, 500000,"63.502.720");
insert into curso (
cod_curs,
nom_cur,
horas_cur,
valor_cur,
doc_curs_prof ) values(
250067, "Fundamentos de SQL", 20, 700000,"91.216.904");
insert into curso (
cod_curs,
nom_cur,
horas_cur,
valor_cur,
doc_curs_prof ) values(
289011, "Manejo de Mysql",45, 550000,"13.826.789");
insert into curso (
cod_curs,
nom_cur,
horas_cur,
valor_cur,
doc_curs_prof ) values(
345671, "Fundamentals of Oracle" ,60, 3000000, "[Link]");
create table Estudiante(
doc_est varchar(30) not null,
nom_est varchar(30) not null,
ape_est varchar(30) not null,
edad_est int not null,
primary key (doc_est)
);
insert into Estudiante () values ("63.502.720", "María", "Pérez", 2);
insert into Estudiante () values ("91.245.678", "Carlos", "José" "López", 3);
insert into Estudiante() values("[Link]", "Jonatan" ,"Ardila",1);
insert into Estudiante() values("[Link]", "Carlos" ,"Martínez",4);
create table estudianteCurso(
cod_cur_estcur int(11) not null,
doc_est_estcur varchar(30) not null,
fec_ini_estcur date not null,
foreign key(cod_cur_estcur) references curso(cod_curs),
foreign key(doc_est_estcur) references Estudiante(doc_est)
);
insert into estudianteCurso () values (89011,"1098765678", '2011-01-02');
insert into estudiantecurso() values(250067, "63502720", '01-03-2011');
insert into estudiantecurso() values(289011, "1098098097" , '01-02-2011');
insert into estudiantecurso() values(345671, "63502720", '01-04-2011');
insert into estudianteCurso (
cod_cur_estcur,
doc_est_estcur,
fec_ini_estcur) values(
289011, "1098765678", '2011-01-02');
create table Cliente;
(id_cli varchar(11)
nom_cli varchar(30) not null,
ape_cli varchar(30) not null,
dir_cli varchar(100) not null,
dep_cli varchar(20) not null,
mes_cum_cli varchar(10) not null,
primary key not null
);
create database Articulos;
Query OK, 1 row affected (0.28 sec)
mysql> use Articulos;
Database changed
mysql>
create table Pedido(
id_pedido int not null auto_increment,
id_cli_ped varchar(11),
fec_ped date not null,
val_ped int not null,
primary key(id_pedido),
foreign key(id_cli_ped) references Cliente(id_cli)
);
create table Articuloxpedido(
id_ped_artped int not null,
id_art_artped int not null,
can_art_artpedint, not null,
val_ven_art_artped int not null,
foreign key(id_ped_artped) references Pedido(id_pedido)
);
create table Compañia(
comnit varchar(11) not null,
comnombre varchar(30) not null,
comañofun int not null,
comreplegal varchar(100)not null
);
create table TiposAutomotores(
autotipo int not null,
primary key (autotipo)
);
create table Automotores(
autoplaca varchar(6) not null,
automarca varchar(30) not null,
autotipo int not null,
automodelo int not null,
autonumpasajeros int not null,
autocilindraje int not null,
autonumchasis varchar(20) not null,
primary key (autoplaca),
foreign key(Autotipo) references TiposAutomotores(autotipo)
);
create table Aseguramientos(
asecodigo int(6) auto_increment not null,
asefechainicio date not null,
asefechaexpiracion date not null,
asevalorasegurado int not null,
aseestado varchar(100) not null,
asecosto int not null,
aseplaca varchar(100) not null,
primary key(asecodigo),
foreign key(aseplaca) references Automotores(autoplaca)
);