practica

Download Practica

If you can't read please download the document

Upload: chuls123

Post on 16-Nov-2015

212 views

Category:

Documents


0 download

DESCRIPTION

letras

TRANSCRIPT

create database Abarrotesgouse abarrotesgocreate table Guia_detalle(idguia int NOT NULL,idproducto Int NOT NULL,precioventa Money NOT NULL,cantidad smallint NOT NULL)gocreate table Orden_detalle(idorden int NOT NULL,idproducto int NOT NULL,preciocompra money NOT NULL,cantidadsolicitada smallint NOT NULL,cantidadrecibida smallint NULL,estado varchar(10) NULL)gocreate table Producto(idproducto int IDENTITY(1,1),idcategoria int NOT NULL,idproveedor int NOT NULL,nombre varchar(40) NOT NULL,unidadmedida varchar(30) NULL,precioproveedor money NULL,stockactual smallint NULL,stockminimo smallint NULL)gocreate table Proveedor(idproveedor int IDENTITY(1,1) not null,nombre varchar(40) NOT NULL,representante varchar(30) NULL,direccin varchar(60) NULL,ciudad varchar(15) NULL,departamento varchar(15) NULL,codigopostal varchar(15) NULL,telefono varchar(15) NULL,fax varchar(15) NULL,descontinuado bit)gocreate table Categoria(idcategoria int IDENTITY(1,1),categoria varchar(20) NOT NULL,descripcin varchar(20) NULL)gocreate table Guia(idguia int NOT NULL,idlocal int NOT NULL,fechasalida datetime NOT NULL,transportista varchar(30) NOT NULL)gocreate table Local1(idlocal int NOT NULL,direccin varchar(60) NULL,distrito varchar(20) NULL,telfono varchar(15) NULL,fax varchar(15) NULL)gocreate table Orden(idorden int NOT NULL,fechaorden datetime NOT NULL,fechaentrada datetime NULL)goalter table guia_detalle add constraint pk_guia primary key(idguia,idproducto)goalter table orden_detalle add constraint pk_orden_detalle primary key(idorden,idproducto)goalter table producto add constraint pk_producto primary key(idproducto)goalter table proveedor add constraint pk_proveedor primary key(idproveedor)goalter table categoria add constraint pk_categoria primary key(idcategoria)goalter table guia add constraint pk_guia1 primary key(idguia)goalter table local1 add constraint pk_local1 primary key(idlocal)goalter table orden add constraint pk_orden primary key(idorden)Foraneasalter table guia_detalle add constraint fk_guia_prodforeign key(idproducto) references producto(idproducto)alter table guia_detalle add constraint fk_guia_guiaforeign key(idguia) references guia(idguia)alter table orden_detalle add constraint fk_ordedet_ordenforeign key(idorden) references orden(idorden)alter table orden_detalle add constraint fk_ordedet_prodforeign key(idproducto) references producto(idproducto)alter table producto add constraint fk_prod_proveedorforeign key(idproveedor) references proveedor(idproveedor)alter table producto add constraint fk_prod_categoriaforeign key(idcategoria) references categoria(idcategoria)alter table guia add constraint fk_guia_localforeign key(idlocal) references local1(idlocal)