Ir al contenido principal

SQLServer - Database INVENTARIO

create database INVENTARIO
go
use INVENTARIO
go

create schema Inv
go

create table Inv.CATEGORIAS
(
id int primary key not null identity(1,1),
cod_categoria int not null, -- como sera clave foranea en otra tabla (en dicha tabla existe como entero)
descrip_Categoria varchar(100)
)
go
select * from inv.CATEGORIAS;
go

create table Inv.TIPOSALIDA
(
id int primary key not null identity(1,1),
cod_tipo_sal int not null, -- como sera clave foranea en otra tabla (en dicha tabla existe como entero)
descrip_tipo_sal varchar(100)
)
go
select * from Inv.TIPOSALIDA;
go


create table Inv.TIPOENTRADA
(
id int primary key not null identity(1,1),
cod_tipo_ent int not null, -- como sera clave foranea en otra tabla (en dicha tabla existe como entero)
descrip_tipo_ent varchar(100)
)
go
select * from Inv.TIPOENTRADA;
go




create table Inv.ENTRADAS
(
id int primary key not null identity(1,1),
num_entrada int not null, -- como sera clave foranea en otra tabla (en dicha tabla existe como entero)
descrip_entrada varchar(100),
fecha_entrada date,
tipoentrada int
constraint fk_tipoentrada_entradas foreign key (num_entrada) references Inv.TIPOENTRADA(id)
)
go
select * from Inv.ENTRADAS;
go



--drop table Inv.SALIDAS

create table Inv.SALIDAS
(
id int primary key not null identity(1,1),
num_salida int not null, -- como sera clave foranea en otra tabla (en dicha tabla existe como entero)
descrip_salida varchar(100),
fecha_salida date,
tiposalida int
constraint fk_tiposalida_salidas foreign key (tiposalida) references Inv.TIPOSALIDA(id)
)
go
select * from Inv.ENTRADAS;
go


create table Inv.PRODUCTOS
(
id int primary key not null identity(1,1),
cod_producto int not null, -- como sera clave foranea en otra tabla (en dicha tabla existe como entero)
descrip_producto varchar(100),
precio_producto money,
categoria_id int
constraint fk_categorias_productos foreign key (categoria_id) references Inv.CATEGORIAS(id)
)
go
select * from Inv.PRODUCTOS;
go

--drop table Inv.DETALLE_ENTRADA
--go

create table Inv.DETALLE_ENTRADA
(id int identity(1,1) primary key,
entrada_id int not null,
producto_id int not null,
cantidad_entrada int not null,
precio_entrada money not null
constraint fk_RODUCTOS_DETALLEENTRADA foreign key (producto_id) references Inv.PRODUCTOS(id),
constraint fk_RODUCTOS_ENTRADA foreign key (entrada_id) references Inv.ENTRADAS(id)
)
go
select * from inv.DETALLE_ENTRADA
go

--drop table Inv.DETALLE_SALIDA
--go

create table Inv.DETALLE_SALIDA
(id int identity(1,1) primary key,
salida_id int not null,
producto_id int not null,
cantidad_salida int not null,
precio_salida money not null
constraint fk_RODUCTOS_DETALLESALIDA foreign key (producto_id) references Inv.PRODUCTOS(id),
constraint fk_RODUCTOS_SALIDA foreign key (salida_id) references Inv.SALIDAS(id)
)
go
select * from inv.DETALLE_SALIDA
go



Comentarios

Entradas populares de este blog

Sistema de Control de Acceso DEMO

fusion de grupos aplicacion 2017 gestion de colegio

EXPLICANDO TAREA PARA ALUMNOS SAB MAT