Sei sulla pagina 1di 5

AP6-AA1-Ev2-Construir la base de datos para su proyecto de formacin

Diego Alejandro Restrepo Flrez

Servicio Nacional de Aprendizaje SENA

Tecnologas de la Informacin y las Comunicaciones Gestin de la Informacin

Anlisis y Desarrollo de Sistemas de Informacin

2017
Create database mometalmec;

Use mometalmec;

Create table taller (id_taller int primary key not null, codigo int, direccion varchar (30),
responsable varchar (25), telefono int);

create table gerente(id_gerente int primary key not null,codigo int,nombre varchar(30),cedula
int,password varchar(30));

Alter table gerente add taller int after id_gerente;

Alter table gerente add constraint fk_ta foreign key(taller) references taller(id_taller);
create table InformeEmpleados(idInformeEmpleados int primary key not null,cargo
varchar(30),nombre varchar(30),cedula int,fecha date,horallegada time,tiemporetrazo
time,horasalida time);

alter table informeempleados add id_gerente int after idinformeempleados;

alter table informeempleados add constraint fk_idge foreign key(id_gerente) references


gerente(id_gerente);

create table empleados (idempleados int primary key not null,cedula int not null,nombre
varchar(30),password varchar(30),direccion varchar(30),correoelectronico varchar(30),telefono
int);

alter table empleados add gerente int;

alter table empleados add constraint fk_ger foreign key(gerente) references gerente(id_gerente);

create table productos(idpriductos int primary key not null,codigo int not null,nombre
varchar(30),material varchar(30),fechapedido date,fechasalida date);

alter table productos add empleados int after idpriductos;

alter table productos add constraint fk_empleado foreign key(empleados) references


empleados(idempleados);
create table proveedores(idproveedor int primary key not null,empleado int,produc int, nombre
varchar(30),direccion varchar(30),correoelectronico varchar(30),telefono int);

alter table proveedores add constraint fk_idempleado foreign key(empleado) references


empleados(idempleados);

alter table proveedores add constraint fkd_idproduc foreign key(produc) references


productos(idpriductos);

create table inventario(idinventario int primary key not null,idgerent int,codigo int not null,fecha
date, nombre varchar(30),existencia int,entrada int,salida int);

alter table inventario add constraint fk_idgeren foreign key(idgerent) references


gerente(id_gerente);

insert into taller values('1','001','call 4 aa #2','alonso','310203017');

select * from taller;

insert into gerente values(2,'1','23','marlon','100232','marl43');

select * from gerente;

insert into informeempleados values(1,'2','operador','carlos','10099',curdate(),'22:00','0','7:00');

select * from informeempleados;


insert into empleados values('4','2','1233','alonso','alo34','calle 4 db # 2','alon@gmail.com',
'28655');

select * from empleados;

insert into productos values(23,'4','245','ventana corredisa','aluminio','2017-08-10',curdate());

select * from productos;

insert into proveedores values(5,'4','23','los fierros','calle 10 # 53','fierros@ejemplo','2865345');

select * from proveedores;

insert into inventario values(1,'2','12',curdate(),'barilla 5/8','20','30','6');

select * from inventario;

Potrebbero piacerti anche