FACTURA DE COMPRAS

Ver el tema anterior Ver el tema siguiente Ir abajo

FACTURA DE COMPRAS

Mensaje  jisela arias el Jue Mar 24, 2011 10:44 pm

create database factura_compra;

use factura_compra

create table bodega(
bodcod int,
stock int,
primary key (bodcod));

use factura_compra

create table proveedor(
procod int,
pronom varchar (max),
protele int,
prodire varchar (max),
procor varchar (max),
primary key (procod));


use factura_compra

create table inventario(
invcod int,
canproe int, --cantidad de productos de entrada
canpros int, --cantidad de productos de salida
stock int,
primary key (invcod));



use factura_compra
create table producto(
prodcod int,
prodnom varchar (max),
prodval int,
procod int,
tprodcod int,
primary key (prodcod),
constraint fk_procod foreign key (procod)references proveedor (procod),
constraint fk_tprodcod foreign key (tprodcod)references tipoproducto (tprodcod));


use factura_compra
create table tipoproducto(
tprodcod int,
tprodnom varchar (max),
invcod int,
primary key (tprodcod),
constraint fk_invcod foreign key (invcod)references inventario (invcod));


use factura_compra
create table pedidocabecera(
pedinrm int,
pedfech varchar (max),
bodcod int,
pedsub int,
pediva real,
pedtot int,
primary key (pedinrm),
constraint fk_bodcod foreign key (bodcod)references bodega (bodcod));




use factura_compra
create table pedidodetalle(
pedinrm int,
prodcod int,
peddcant int,
peddvalu int, --valor unitario
peddtotal int,
constraint fk_pedinrm foreign key (pedinrm)references pedidocabecera (pedinrm),
constraint fk_prodcod foreign key (prodcod)references producto (prodcod));


use factura_compra
--tabla proveedor
insert into proveedor values (01,'laura cortes',6543226,'cll 72 w 04-34','lauc@hotmail.com'),(02,'lina copete',6548526,'cr 23 u 24-34','lina@hotmail.com'),(03,'daniela rodriguez',7896541,'cll 84 v 72-34','dani@hotmail.com'),(04,'giselle vargas',651236,'cll 10 w 11-34','dani@hotmail.com'),(05,'diego suarez',6589321,'av 56 b 56-34','diego@hotmail.com'),(06,'marcela puche',6650236,'diagonal 05 a 89-72','marce@hotmail.com'),(07,'carlos perez',6654826,'cll 12 d 04-34','carlos@hotmail.com'),(08,'edwin ramos',6548916,'av 12 b 56-30','edwin@hotmail.com'),(09,'diana lopez',9532214,'diagonal 13 b 46-93','diana@hotmail.com'),(10,'julieth correa',4568971,'av 56 d 05-38','juli@hotmail.com');

--tabla inventario
insert into inventario values (1,50,5,45),(2,40,10,30),(3,100,50,50),(4,200,10,190),(5,150,5,145),(6,45,5,40),(7,250,60,190),(8,60,5,55),(9,130,15,115),(10,70,5,65);

--tabla bodega
insert into bodega values (1,45),(2,30),(3,50),(4,190),(5,145),(6,40),(7,190),(8,55),(9,115),(10,65);


--tabla tipo de producto
insert into tipoproducto values(11,'nike',1),(12,'adidas',2),(13,'levis',3),(14,'puma',4),(15,'zara',5),(16,'diesel',6),(17,'tommy',7),(18,'calvin klein',Cool,(19,'la coste',9),(20,'offcorss',10);

--tabla producto
insert into producto values(1,'gorra',50000,01,11),(2,'zapatillas',200000,02,12),(3,'blusa',80000,03,13),(4,'camiseta',80000,04,14),(5,'jean',150000,05,15),(6,'zapatos',200000,06,16),(7,'zapatos',150000,07,17),(8,'panti',50000,08,18),(9,'gorra',30000,09,19),(10,'jean',60000,10,20);


--tabla pedido cabecera
insert into pedidocabecera values(1,'1999-12-01',1,50000,0.16,58000),(2,'2011-11-03',2,200000,0.16,232000),(3,'2010-10-05',3,160000,0.20,192000),(4,'2009-13-06',4,240000,0.5,360000),(5,'2008-15-01',5,300000,0.6,480000),(6,'2003-1-03',6,200000,0.2,240000),(7,'2000-1-03',7,750000,0.15,862500),(8,'2004-10-04',8,50000,0.1,55000),(9,'2006-11-03',9,60000,0.6,96000),(10,'2009-6-06',10,60000,0.2,72000);


--tabla pedido detalle
insert into pedidodetalle values(1,1,1,50000,50000),(2,2,1,200000,200000),(3,3,2,80000,160000),(4,4,3,80000,240000),(5,5,2,150000,300000),(6,6,1,200000,200000),(7,7,5,150000,750000),(8,8,1,50000,50000),(9,9,2,30000,60000),(10,10,1,60000,60000);



MER:
http://img22.imageshack.us/img22/8143/diagrama1.jpg

Relación de tablas:
http://img820.imageshack.us/img820/1481/diapositiva1zd.jpg
avatar
jisela arias

Mensajes : 5
Fecha de inscripción : 10/02/2011

Ver perfil de usuario

Volver arriba Ir abajo

Ver el tema anterior Ver el tema siguiente Volver arriba

- Temas similares

 
Permisos de este foro:
No puedes responder a temas en este foro.