Sie sind auf Seite 1von 2

create database julio

use julio

create table local1


(id int not null primary key,
direccion varchar (40) not null,
distrito varchar (40) not null,
telefono numeric (18,0) not null,
fax varchar (40) not null)

create table guia


(id int identity not null primary key,
idlocal1 int,
fechasalida date not null,
transportista varchar (40) not null

constraint fk_guia_idlocal1 foreign key (idlocal1) references local1(id))

--sin ejecutar

create table proveedor


(id int not null primary key,
nombre varchar (40) not null,
representante varchar (30) not null,
direccion varchar (40) not null,
ciudad varchar (30) not null,
departamento varchar not null,
codigo_postal numeric (18,0) not null,
telefono numeric (18,0) not null,
fax varchar (30) not null)

create table categoria


(id int not null primary key,
categoria varchar (40) not null,
descripcion varchar (30) not null)

create table producto


(id int identity not null primary key,
idcategoria int,
idproveedor int,
nombre varchar (40) not null,
unidadamedida varchar (40) not null,
precioproveedor money not null,
stockactual numeric (8,0) not null,
stockminimo numeric (8,0) not null,
descontinuado varchar (40) not null

constraint fk_producto_idcategoria foreign key (idcategoria) references


categoria(id),
constraint fk_producto_idproveedor foreign key (idproveedor) references
proveedor(id))

create table guia_detalle


(id int identity not null primary key,
idguia int,
idproducto int,
precio_venta money not null,
cantidad numeric (18,0) not null
constraint fk_guia_detalle_idguia foreign key (idguia) references guia(id),
constraint fk_guia_detalle_idproducto foreign key (idproducto) references
producto(id))

create table orden


(id int not null primary key,
fecha_orden date not null,
fecha_entrada date not null)

create table orden_detalle


(id int identity not null primary key,
idorden int,
idproducto int,
preciocompra money not null,
cantidadsolicitada numeric (18,0) not null,
cantidadrecibida numeric (18,0) not null,
estado varchar (40) not null

constraint fk_orden_detalle_idorden foreign key (idorden) references orden(id),


constraint fk_orden_detalle_idproducto foreign key (idproducto) references
producto(id))

Das könnte Ihnen auch gefallen