You are on page 1of 3

create database bdmercadovega

sp_helpdb
use bdmercadovega
create table cliente
(codcliente
char(6)
not null primary key,
nom
varchar(60) not null,
direc
varchar(60) not null,
dni
char(8)
not null,
fecha_registro datetime not null,
sueldo
numeric(8,2)not null,
estado_civil varchar(10) not null)
create table vendedor
(codvendedor char(6)
not null primary key,
nom
varchar(60) not null,
sueldo
numeric(8,2) not null,
turno
varchar(10) not null)
create table categoria
(codcategoria char(6)
not null primary key,
nomcateg
varchar(60) not null)
create table factura
(nrofactura char(12)
not null primary key,
femision datetime
not null,
forma_pago varchar(12) not null,
subtotal numeric(8,2) not null,
IGV
numeric(8,2) not null,
total
numeric(8,2) not null,
codcliente char(6)
not null foreign key(codcliente) references
cliente(codcliente),
codvendedor char(6)
not null foreign key(codvendedor) references
vendedor(codvendedor))
create table productos
(codproducto char(8)
not null primary key,
descripcion varchar(60) not null,
precio
numeric(8,2)not null,
marca
varchar(50) not null,
fvenci
datetime not null,
codcategoria char(6)
not null foreign key(codcategoria) references
categoria(codcategoria))
create table detalle

(nrofactura char(12)
not null foreign key(nrofactura) references
factura(nrofactura),
codproducto char(8)
not null foreign key(codproducto) references
productos(codproducto),
cantidad
varchar(10) not null,
importe
numeric(8,2) not null)
select*
select*
select*
select*
select*
select*

from
from
from
from
from
from

cliente
vendedor
factura
productos
categoria
detalle

sp_help
set dateformat DMY
insert into
cliente(codcliente,nom,direc,dni,fecha_registro,sueldo,estado_civil)
values('C00001','Juan','Jr. bustamante y rivero mz 10s lote
8','42806734','02/10/16','2000','soltero')
insert into
cliente(codcliente,nom,direc,dni,fecha_registro,sueldo,estado_civil)
values('C00002','Mario','Jr. Jose Santos Chocano mz 4b lote
16','44289123','02/10/16','3500','casado')
select* from cliente
insert into vendedor(codvendedor,nom,sueldo,turno)
values('A00001','John','1250','Maana')
insert into vendedor(codvendedor,nom,sueldo,turno)
values('A00002','Mirtha','1500','Noche')
select* from vendedor
insert into
factura(nrofactura,femision,forma_pago,subtotal,IGV,total,codcliente,cod
vendedor) values('00100000001','07/10/16','Tarjeta','700','133','833','C00001','A00001')
insert into
factura(nrofactura,femision,forma_pago,subtotal,IGV,total,codcliente,cod
vendedor) values('00100000002','08/10/16','Efectivo','750','143','893','C00002','A00002')
insert into
factura(nrofactura,femision,forma_pago,subtotal,IGV,total,codcliente,cod
vendedor) values('00100000003','09/10/16','Efectivo','820','156','976','C00001','A00002')

select* from factura


insert into categoria(codcategoria,nomcateg)
values('A01234','desayuno')
insert into categoria(codcategoria,nomcateg)
values('A02345','almuerzo')
select* from categoria
insert into
productos(codproducto,descripcion,precio,marca,fvenci,codcategoria)
values('60288','arroz','2.50','paisana','22/11/17','A02345')
insert into
productos(codproducto,descripcion,precio,marca,fvenci,codcategoria)
values('40223','azucar','3.00','margarita','12/12/18','A01234')
insert into
productos(codproducto,descripcion,precio,marca,fvenci,codcategoria)
values('15478','leche','3.20','gloria','10/03/17','A01234')
insert into
productos(codproducto,descripcion,precio,marca,fvenci,codcategoria)
values('22345','menestra','1.80','costea','09/04/19','A02345')
select* from productos
insert into detalle(nrofactura,codproducto,cantidad,importe)
00000001','60288','2kilos','5.00')
insert into detalle(nrofactura,codproducto,cantidad,importe)
00000002','40223','1/2kilo','1.50')
insert into detalle(nrofactura,codproducto,cantidad,importe)
00000003','15478','1litro','3.20')
insert into detalle(nrofactura,codproducto,cantidad,importe)
00000002','22345','900gramos','1.80')
insert into detalle(nrofactura,codproducto,cantidad,importe)
00000001','15478','1kilo','2.50')
select* from detalle

values('001values('001values('001values('001values('001-

You might also like