aa
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
/*==============================================================*/
/* 建立数据库DCM
/*==============================================================*/
create DataBase DCM
/*==============================================================*/
/* Table: Address 地址表
/*==============================================================*/
create table Address (
addressID int identity,
addressName varchar(50) null,
parentID int null,
adddate datetime null default getdate(),
constraint PK_ADDRESS primary key (addressID)
)
go
/*==============================================================*/
/* Table: AdjustCase 建立调整原因表 */
/*==============================================================*/
create table AdjustCase (
AdjustCaseID int identity,
AdjustCaseText varchar(1000) null,
Userid int null,
adddate datetime not null default getdate(),
constraint PK_ADJUSTCASE primary key (AdjustCaseID)
)
go
/*==============================================================*/
/* Table: AdminMenu 建立管理员菜单表 */
/*==============================================================*/
create table AdminMenu (
menuID int identity,
menuName varchar(50) null,
menuHref varchar(100) null,
parentID int null,
adddate datetime null default getdate(),
constraint PK_ADMINMENU primary key (menuID)
)
go
/*==============================================================*/
/* Table: AdminType 建立管理员类型表 */
/*==============================================================*/
create table AdminType (
admintypeid int identity,
typename varchar(50) null,
adddate datetime null default getdate(),
constraint PK_ADMINTYPE primary key (admintypeid)
)
go
/*==============================================================*/
/* Table: BackCase 建立退货原因表 */
/*==============================================================*/
create table BackCase (
BackCaseID int identity,
CaseText varchar(1000) null,
userid int null,
adddate datetime not null default getdate(),
constraint PK_BACKCASE primary key (BackCaseID)
)
go
/*==============================================================*/
/* Table: Breeds 建立品牌表 */
/*==============================================================*/
create table Breeds (
breedid int identity,
breedName varchar(20) null,
corporationID int null,
breedImgurl varchar(200) null,
adddate datetime null default getdate(),
constraint PK_BREEDS primary key (breedid)
)
go
/*==============================================================*/
/* Table: Categories 建立产品类别表
/*==============================================================*/
create table Categories (
categoryID int identity,
categoryName varchar(20) null,
adddate datetime null default getdate(),
constraint PK_CATEGORIES primary key (categoryID)
)
go
/*==============================================================*/
/* Table: ClassOnce 建立班次表
/*==============================================================*/
create table ClassOnce (
OneceID numeric identity,
OneceName varchar(50) null,
AddDate datetime null default getdate(),
constraint PK_CLASSONCE primary key (OneceID)
)
go
/*==============================================================*/
/* Table: Corporations 建立企业表
/*==============================================================*/
create table Corporations (
corporationID int identity,
corporationName varchar(20) null,
corporationImgurl varchar(200) null,
orderIndex int null,
adddate datetime null default getdate(),
constraint PK_CORPORATIONS primary key (corporationID)
)
go
/*==============================================================*/
/* Table: DB_BACK 建立数据库备份表
/*==============================================================*/
create table DB_BACK (
backID int identity,
backName varchar(50) null,
backPath varchar(200) null,
backAdmin varchar(50) null,
backDate datetime null default getdate(),
constraint PK_DB_BACK primary key (backID)
)
go
/*==============================================================*/
/* Table: Permissions 建立权限表
/*==============================================================*/
create table Permissions (
PermissionID int identity,
Rol_roleid int null,
RoleID int null,
PermissionName varchar(20) null,
adddate datetime null default getdate(),
constraint PK_PERMISSIONS primary key (PermissionID)
)
go
/*==============================================================*/
/* Table: Products 建立产品表
/*==============================================================*/
create table Products (
productid int identity,
storageID int null,
productName varchar(50) null,
price decimal(18,2) null,
categoryID int null,
quantity int null,
productxh varchar(50) null,
adddate datetime null default getdate(),
constraint PK_PRODUCTS primary key (productid)
)
go
/*==============================================================*/
/* Table: Roles 建立角色表
/*==============================================================*/
create table Roles (
roleid int identity,
rolename varchar(50) null,
addate datetime null default getdate(),
constraint PK_ROLES primary key (roleid)
)
go
/*==============================================================*/
/* Table: SCenter 建立库存中心表
/*==============================================================*/
create table SCenter (
SCenterID int identity,
SCenterName varchar(50) null,
AddDate datetime null default getdate(),
constraint PK_SCENTER primary key (SCenterID)
)
go
/*==============================================================*/
/* Table: Storages 建立库存表 */
/*==============================================================*/
create table Storages (
storageID int identity,
SCenterID int null,
storageName varchar(50) null,
quantity int null,
outquantity int null,
adddate datetime null default getdate(),
constraint PK_STORAGES primary key (storageID)
)
go
/*==============================================================*/
/* Table: StreamLine 建立流水线表
/*==============================================================*/
create table StreamLine (
LineID int identity,
LineName varchar(50) null,
adddate datetime null default getdate(),
constraint PK_STREAMLINE primary key (LineID)
)
go
/*==============================================================*/
/* Table: UnitTable 建立单位表
/*==============================================================*/
create table UnitTable (
UnitID int identity,
UnitName varchar(50) null,
adddate datetime null default getdate(),
constraint PK_UNITTABLE primary key (UnitID)
)
go
/*==============================================================*/
/* Table: Users 建立用户表
/*==============================================================*/
create table Users (
userid int identity,
admintypeid int null,
username varchar(20) null,
password varchar(100) null,
realname varchar(10) null,
gender varchar(5) null,
email varchar(50) null,
roleid int null,
lastlogin datetime null,
regdate datetime null default getdate(),
constraint PK_USERS primary key (userid)
)
go
/*==============================================================*/
/* Table: Ways 建立路线表
/*==============================================================*/
create table Ways (
wayID int identity,
wayName varchar(100) null,
wayStart varchar(50) null,
wayEnd varchar(50) null,
adddate datetime null default getdate(),
constraint PK_WAYS primary key (wayID)
)
go
/* 建立品牌和企业表外键的关系 */
alter table Breeds
add constraint FK_BREEDS_REFERENCE_CORPORAT foreign key (corporationID)
references Corporations (corporationID)
go
/* 建立权限表和角色表外键的关系 */
alter table Permissions
add constraint FK_PERMISSI_REFERENCE_ROLES foreign key (Rol_roleid)
references Roles (roleid)
go
/* 建立产品表和库存表外键的关系 */
alter table Products
add constraint FK_PRODUCTS_REFERENCE_STORAGES foreign key (storageID)
references Storages (storageID)
go
/* 建立产品表和产品类型表外键的关系 */
alter table Products
add constraint FK_PRODUCTS_REFERENCE_CATEGORI foreign key (categoryID)
references Categories (categoryID)
go
/* 建立用户与其管理员类型表之间的外键关系 */
alter table Users
add constraint FK_USERS_REFERENCE_ADMINTYP foreign key (admintypeid)
references AdminType (admintypeid)
go
/* 建立用户与角色表外键的关系 */
alter table Users
add constraint FK_USERS_REFERENCE_ROLES foreign key (roleid)
references Roles (roleid)
go