📄 database.sql
字号:
--DatabaseName: logistic
use master
go
if exists(select * from sysdatabases where name = 'logistic')
drop database logistic
go
create database logistic
go
use logistic
go
--创建表1:商品分类表
--1、CommCateTable(商品分类表)
create table commcatetable (
Id int identity primary key, --商品分类表自动编号
CommodityId varchar(20), --商品分类编号
CommodityName varchar(20) --商品分类名称
)
--创建表2:部门信息表
--2、DepartmentInfoTable(部门信息表)
create table departmentinfotable (
Id int identity primary key, --部门信息表自动编号
DepartmentId varchar(20) NOT NULL,--部门编号
DepartmentName varchar(20) NOT NULL--部门名称
)
-- 创建表3:学历信息表
--3、DiplomaInfoTable(学历信息表)
create table diplomainfotable (
Id int identity primary key, --学历信息表自动编号
DiplomaName varchar(20) NOT NULL --学历名称
)
-- 创建表4 :职务信息表
--4、JobsInfoTable(职务信息表)
create table jobsinfotable (
Id int identity primary key, --职务信息表自动编号
JobsId varchar(20) NOT NULL, --职务编号
JobsName varchar(20) NOT NULL, --职务名称
DescribleJobs varchar(50) --职务描述
)
--创建表5:商品在库区域表
--5、GoodsLocationTable(商品在库区域表)
create table goodslocationtable (
Id int identity primary key, --商品在库区域表自动编号
LocationId varchar(20) NOT NULL, --商品位置Id
LocationName varchar(20) NOT NULL --商品位置名称
)
--创建表6:商品摆放排号表
--6、GoodsRowsTable(商品摆放排号表)
create table goodsrowstable (
Id int identity primary key, --商品摆放排号表自动编号
RowsId varchar(20) NOT NULL, --排号Id
RowsName varchar(20) NOT NULL --排号名称
)
--创建表7:商品摆放座号表
--7、GoodsSeatsTable(商品摆放座号表)
create table goodsseatstable (
Id int identity primary key, --商品摆放座号表自动编号
SeatsId varchar(20) NOT NULL, --商品位Id
SeatsName varchar(20) NOT NULL --商品位名称
)
-- 创建表8:商品在库位置表
--8、StockRegionInfoTable(商品在库位置表)
create table stockregioninfotable (
Id int identity primary key, --商品在库位置表自动编号
StockRegionId varchar(20) NOT NULL, --在库位置编号
StockRegionName varchar(20) NOT NULL --在库位置名称
)
--创建表9: 供应商信息表
--9、SupplyTable(供应商信息表)
create table supplytable (
Id int identity primary key, --供应商信息表自动编号
SupplyId varchar(20) NOT NULL, --供应商Id
SupplyName varchar(50) NOT NULL, --供应商名称
SupplyCharge varchar(30) NOT NULL, --供应商负责人
SupplyAddress varchar(50) NOT NULL, --供应商地址
SupplyPhone varchar(20) NOT NULL, --供应商固定电话
SupplyMobile varchar(20) NOT NULL, --供应商移动电话
SupplyFax varchar(20) default NULL, --供应商传真
SupplyEmail varchar(50) default NULL, --供应商电子邮件
SupplyHttp varchar(50) default NULL --供应商网址
)
-- 创建表10:职员信息表
--10、EmployeeInfoTable(职员信息表)(注:DepartmentId,JobsId为外键)
create table employeeinfotable (
Id int identity primary key, --职员信息表自动编号
EmployeeId varchar(20) NOT NULL, --职员编号
EmployeeName varchar(20) NOT NULL, --职员姓名
EmployeeSex varchar(4) NOT NULL, --职员性别
EmployeeAge int NOT NULL, --职员年龄
EmployeeIdenCard varchar(20) NOT NULL, -- 职员身份证号,
EmployeeBirthDate varchar(20) default NULL, -- 职员出生日期,
EmployeeDiploma varchar(20) NOT NULL, --职员学历,
EmployeeJoinDate varchar(20) default NULL, --职员加入公司日期,
EmployeeAdd varchar(50) NOT NULL, --职员家庭住址,
EmployeePhone varchar(20) default NULL, --职员固定电话,
EmployeeMobile varchar(20) default NULL, --职员移动电话,
DepartmentId int NOT NULL foreign key references departmentinfotable(Id) on delete cascade on update cascade, --职员所属部门编号,
JobsId int NOT NULL foreign key references jobsinfotable(Id)on delete cascade on update cascade --职员的职务编号,
)
--创建表11:车队信息表
--11、CarTeamInfoTable(车队信息表)(注:ChargeId为外键)
create table carteaminfotable (
Id int identity primary key, --车队信息表自动编号
CarTeamId varchar(20) NOT NULL, --车队编号
CarTeamName varchar(20) NOT NULL, --车队名称
ChargeId int foreign key references employeeinfotable(Id) on delete cascade on update cascade --车队负责人编号
)
-- 创建表12:车辆管理表
--12、CarManageTable(车辆管理表)(注:CarDriverId、CarTeamId为外键)
create table carmanagetable (
Id int identity primary key, --车辆管理表自动编号
CardId varchar(20) NOT NULL, --车辆牌号
CarDriverId int foreign key references employeeinfotable(Id) on delete cascade on update cascade NOT NULL, --驾驶员编号
CarTeamId int foreign key references carteaminfotable(Id) --所属车队编号
)
--创建表13:登陆管理表
--13、LoginTable (登陆管理表)(注:EmployeeId为外键)
create table logintable (
Id int identity primary key, --登陆管理表自动编号
LoginId varchar(20) NOT NULL, --登陆职员编号Id
LoginName varchar(20) NOT NULL, --登陆职员姓名
LoginPassword varchar(20) NOT NULL, --登陆职员密码
LoginPower varchar(20) NOT NULL, --登陆职员权限
EmployeeId int foreign key references EmployeeInfoTable(Id) on delete cascade on update cascade --职员编号
)
--创建表14:公告信息表
--14、MessageInfoTable(公告信息表)
create table messageinfotable (
Id int identity primary key, --公告信息表自动编号
MessageId varchar(20) NOT NULL, --公告信息Id
EmployeeId int foreign key references EmployeeInfoTable(Id) on delete cascade on update cascade, --发布公告的职员Id
MessageTitle varchar(50) NOT NULL, --公告标题
MessageTime varchar(20) NOT NULL, --公告发布时间
MessageContent varchar(500) NOT NULL --公告内容
)
--创建表15:商品型号信息表
--15、TypeTable(商品型号信息表)
create table typetable (
Id int identity primary key, --商品型号信息表自动编号
TypeId varchar(20) NOT NULL, --商品型号Id
TypeName varchar(20) NOT NULL, --商品型号名称
CategoryId int foreign key references commcatetable(Id) on delete cascade on update cascade --商品分类Id
)
--创建表16:仓储信息表
--16、WareHouseInfoTable(仓储信息表)
create table warehouseinfotable (
Id int identity primary key, --仓储信息表自动编号
WareHouseId varchar(20) NOT NULL, --仓库Id
WareHouseName varchar(100) NOT NULL, --仓库名称
ChargeId int foreign key references employeeinfotable(Id)on delete cascade on update cascade, --仓库负责人Id
WareHouseAdd varchar(100) NOT NULL --仓库地址
)
-- 创建表17:商品信息表
--17、GoodsInfoTable(商品信息表)(注:GoodsCateId、GoodsSupplyId、GoodsStockId、StockRegionId、TypeId为外键)
create table goodsinfotable (
Id int identity primary key, --商品信息表自动编号
GoodsId varchar(20) NOT NULL, --商品Id,
GoodsName varchar(20) NOT NULL, --商品名称,
GoodsCateId int NOT NULL foreign key references typetable(Id)on delete cascade on update cascade, --商品分类Id,
GoodsSupplyId int NOT NULL foreign key references supplytable(Id)on delete cascade on update cascade, --商品供应商Id,
GoodsABC varchar(10) NOT NULL, --商品ABC分类,
GoodsProvince varchar(20) NOT NULL, --商品产地省,
GoodsCity varchar(20) NOT NULL, --商品产地市,
GoodsStockId int NOT NULL foreign key references stockregioninfotable(Id)on delete cascade on update cascade, --商品所在仓库Id,
GoodsPrice float NOT NULL, --商品单价,
GoodsStockNumber int NOT NULL, --商品存入量,
GoodsOrderDate varchar(20) NOT NULL, --商品定购日期,
GoodsStockInDate varchar(20) NOT NULL, --商品入库日期,
GoodsUnit varchar(4) NOT NULL, --商品单位,
TypeId int NOT NULL foreign key references typetable(Id) --商品型号Id,
)
--创建表18:入库单信息表
--18、StockInInfoTable(入库单信息表) (注:ChargId、GoodsId、TypeId为外键)
create table stockininfotable (
Id int identity primary key, --入库单信息表自动编号
StockInId varchar(20) NOT NULL, --入库单Id
StockInDate varchar(20) NOT NULL, --入库单生成时间
ChargeId int foreign key references EmployeeInfoTable(Id) on delete cascade on update cascade, --负责人Id
GoodsId int foreign key references GoodsInfoTable(Id) on delete cascade on update cascade, --入库商品Id
GoodsInNumber int NOT NULL, --商品入库量
TypeId int foreign key references TypeTable(Id) , --入库商品型号Id
CommodityId int foreign key references CommCateTable(Id) , --入库商品分类Id
GoodsInMemo varchar(100) default NULL --入库备注信息
)
--创建表19:出库单信息表
--19、StockOutInfoTable(出库单信息表)(注:ChargeId、GoodsId、GoodsReceiveId、TypeId、CommodityId)
create table stockoutinfotable (
Id int identity primary key, --出库单信息表自动编号
StockOutId varchar(20) NOT NULL, --出库单Id
StockOutDate varchar(20) NOT NULL, --出库单生成日期
ChargeId int foreign key references EmployeeInfoTable(Id) on delete cascade on update cascade, --出库单负责人
GoodsId int foreign key references GoodsInfoTable(Id) on delete cascade on update cascade, --出库商品Id
GoodsOutNumber int NOT NULL, --商品出库量
GoodsReceivePerson varchar(20) NOT NULL, --商品接受人
TypeId int foreign key references TypeTable(Id) , --商品型号Id
CommodityId int foreign key references CommCateTable(Id) , --商品分类Id
GoodsOutMemo varchar(100) default NULL --出库单备注信息
)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -