/*==============================================================*/
/* DBMS name: Microsoft SQL Server 2008 */
/* Created on: 2018/6/28 21:08:54 */
/*==============================================================*/
if exists (select 1
from sysobjects
where id = object_id('仓库')
and type = 'U')
drop table 仓库
go
if exists (select 1
from sysindexes
where id = object_id('入库')
and name = 'Reference_5_FK'
and indid > 0
and indid < 255)
drop index 入库.Reference_5_FK
go
if exists (select 1
from sysobjects
where id = object_id('入库')
and type = 'U')
drop table 入库
go
if exists (select 1
from sysindexes
where id = object_id('入库信息')
and name = 'Reference_6_FK'
and indid > 0
and indid < 255)
drop index 入库信息.Reference_6_FK
go
if exists (select 1
from sysobjects
where id = object_id('入库信息')
and type = 'U')
drop table 入库信息
go
if exists (select 1
from sysindexes
where id = object_id('出库')
and name = 'Reference_4_FK'
and indid > 0
and indid < 255)
drop index 出库.Reference_4_FK
go
if exists (select 1
from sysobjects
where id = object_id('出库')
and type = 'U')
drop table 出库
go
if exists (select 1
from sysindexes
where id = object_id('出库信息')
and name = 'Reference_7_FK'
and indid > 0
and indid < 255)
drop index 出库信息.Reference_7_FK
go
if exists (select 1
from sysobjects
where id = object_id('出库信息')
and type = 'U')
drop table 出库信息
go
if exists (select 1
from sysindexes
where id = object_id('库存')
and name = 'Reference_9_FK'
and indid > 0
and indid < 255)
drop index 库存.Reference_9_FK
go
if exists (select 1
from sysobjects
where id = object_id('库存')
and type = 'U')
drop table 库存
go
if exists (select 1
from sysindexes
where id = object_id('盘点作业')
and name = 'Reference_10_FK'
and indid > 0
and indid < 255)
drop index 盘点作业.Reference_10_FK
go
if exists (select 1
from sysobjects
where id = object_id('盘点作业')
and type = 'U')
drop table 盘点作业
go
if exists (select 1
from sysindexes
where id = object_id('货物')
and name = 'Reference_3_FK'
and indid > 0
and indid < 255)
drop index 货物.Reference_3_FK
go
if exists (select 1
from sysobjects
where id = object_id('货物')
and type = 'U')
drop table 货物
go
if exists (select 1
from sysindexes
where id = object_id('采购')
and name = 'Reference_8_FK'
and indid > 0
and indid < 255)
drop index 采购.Reference_8_FK
go
if exists (select 1
from sysobjects
where id = object_id('采购')
and type = 'U')
drop table 采购
go
if exists (select 1
from sysindexes
where id = object_id('销售')
and name = 'Reference_11_FK'
and indid > 0
and indid < 255)
drop index 销售.Reference_11_FK
go
if exists (select 1
from sysobjects
where id = object_id('销售')
and type = 'U')
drop table 销售
go
/*==============================================================*/
/* Table: 仓库 */
/*==============================================================*/
create table 仓库 (
仓库编号 char(5) not null,
仓库名称 char(20) null,
仓库地址 char(20) null,
constraint PK_仓库 primary key nonclustered (仓库编号)
)
go
/*==============================================================*/
/* Table: 入库 */
/*==============================================================*/
create table 入库 (
入库单号 varchar(10) not null,
库存_货物编号 char(5) null,
仓库编号 char(5) null,
货物编号 char(5) null,
入库量 int null,
入库时间 timestamp null,
constraint PK_入库 primary key nonclustered (入库单号),
constraint AK_IDENTIFIER_1_入库 unique (入库单号)
)
go
/*==============================================================*/
/* Index: Reference_5_FK */
/*==============================================================*/
create index Reference_5_FK on 入库 (
库存_货物编号 ASC
)
go
/*==============================================================*/
/* Table: 入库信息 */
/*==============================================================*/
create table 入库信息 (
产品质量 binary(1) null,
采购商编号 char(5) not null,
采购编号 char(5) not null,
入库单号 varchar(10) null,
constraint PK_入库信息 primary key nonclustered (采购编号)
)
go
/*==============================================================*/
/* Index: Reference_6_FK */
/*==============================================================*/
create index Reference_6_FK on 入库信息 (
入库单号 ASC
)
go
/*==============================================================*/
/* Table: 出库 */
/*==============================================================*/
create table 出库 (
出库单号 varchar(10) not null,
库存_货物编号 char(5) null,
仓库编号 char(5) null,
货物编号 char(5) null,
出库量 int null,
出库时间 timestamp null,
constraint PK_出库 primary key nonclustered (出库单号)
)
go
/*==============================================================*/
/* Index: Reference_4_FK */
/*==============================================================*/
create index Reference_4_FK on 出库 (
库存_货物编号 ASC
)
go
/*==============================================================*/
/* Table: 出库信息 */
/*==============================================================*/
create table 出库信息 (
出库质量 binary(1) null,
销售商编号 char(5) null,
出库编号 char(5) not null,
出库单号 varchar(10) null,
constraint PK_出库信息 primary key nonclustered (出库编号)
)
go
/*==============================================================*/
/* Index: Reference_7_FK */
/*==============================================================*/
create index Reference_7_FK on 出库信息 (
出库单号 ASC
)
go
/*=============================================