超市进销存系统 数据库设计报告

超市进销存系统 数据库设计报告

注意:本设计报告省略了需求分析部分、实体说明、联系说明、索引说明等,重点是数据库的实现过程以及sql语言的编写以及其他一些我认为的重点展示
另外:本系统前期主要使用了软件PowerDesigner,从需求分析到模型设计、约束条件、视图、业务规则等,都是用的该软件。

产品简介

超市进销存系统主要为商品的进货上架、销售收银、仓库存储提供线上管理的功能。

目标客户:中小型超市

客户的业务需求:

  1. 改变传统的人工管理,实现日常管理信息化;

  2. 通过对库存和销售信息的快速查询和处理,提高商品的采购的速度和科学性;

  3. 提升超市管理水平,降低经营成本,提高工作效率。

本系统的总体框架
这里写图片描述


数据模型

BPM模型
这里写图片描述
CDM 模型
这里写图片描述
PDM模型
这里写图片描述

部分存储器、触发器、函数的设计

本人负责的是关于存货模块的存储器、触发器、函数设计,这里举了几个例子:

  • 存储器设计1、
/*具有“采购员”职称的员工加薪15%,“理货员”加薪10%,“收银员”加薪5%,“经理”加薪20%*/
create procedure proc_raise
as
declare cur cursor for select workerNum,job from t_user
declare @increment decimal(2,1)
declare @num int
declare @tjob varchar(50)
open cur
fetch next from cur into @num,@tjob
while(@@fetch_status=0)
begin
if @tjob='采购员' set @increment=0.15
else if @tjob='理货员'set @increment=0.1
else if @tjob='收银员' set @increment=0.05
else if @tjob='经理' set @increment=0.2
update t_user
set salary=salary*(1+@increment)
where workerNum=@num
fetch next from cur into @num,@tjob
end
close cur
deallocate cur
go

测试结果:
未执行存储器之前的员工表:
这里写图片描述

执行加薪功能的的存储器之后:

execute proc_raise

这里写图片描述

  • 存储器设计2、
/*清空库存信息表:t_inventory钟库存量为0的商品信息*/
create procedure proc_amount0
as
declare cur cursor for select goodsNum,amount from t_inventory
declare @gnum int
declare @gamount int
open cur
fetch next from cur into @gnum,@gamount
while(@@fetch_status=0)
begin
if @gamount=0
delete from t_inventory
where goodsNum=@gnum
fetch next from cur into @gnum,@gamount
end
close cur
deallocate cur

测试结果:
未执行存储器之前的t_inventory:
这里写图片描述

执行存储器:

execute proc_amount0

这里写图片描述

  • 用户自定义函数设计1、
/*输入商品编号,在t_goodsOn表上将该商品标注为' 促销-买一送一'*/

create function dbo.func_num_cuxiao(@gnum int)
returns varchar(50)
as
begin
declare @gname varchar(50);
declare @gprice int;
select @gname=goodsName from t_goodsOn where t_goodsOn.goodsNum=@gnum;
select @gprice=price from t_goodsOn where t_goodsOn.goodsNum=@gnum;
set @gname=@gname+'促销-买一送一';
return @gname
end

declare @t varchar(50)
execute @t= dbo.func_num_cuxiao "01";
update t_goodsOn
set goodsName=@t where goodsNum=01 ;
select *from t_goodsOn

测试结果:
这里写图片描述

  • 用户自定义函数设计2、
/*对于库存量小于10的商品,备注remark里面添加“库存紧张!!!”的字段*/
create function dbo.func_less(@gnum int)
returns varchar(50)
as 
begin
declare @mark varchar(50)
set @mark='库存紧张!!!'+(select remark from t_inventory where goodsNum=@gnum)
return @mark
end

create procedure proc_tmp
as
declare cur cursor for select goodsNum from t_inventory
declare @gnum int
declare @ta int 
declare @t varchar(50)
open cur
fetch next from cur into @gnum
while(@@fetch_status=0)
begin
select @ta=amount from t_inventory where goodsNum=@gnum
if @ta<10
begin
execute @t= dbo.func_less @gnum ;
update t_inventory
set remark=@t where goodsNum=@gnum ;
end
fetch next from cur into @gnum
end
close cur
deallocate cur

结果测试:
原来的库存信息表t_inventory:
这里写图片描述

execute proc_tmp

执行之后:
这里写图片描述

  • 触发器设计1、
/*触发器:t_goodsBuy商品进价变,t_incentory的同商品的进价也变,售价+(现进价-原进价),t_goodsSale商品售价也变*/
create trigger tri_alter_cost
on dbo.t_goodsBuy
after insert
as
begin 
declare @num int;
declare cur cursor for select goodsNum from inserted;
open cur;
fetch from cur into @num;
while @@FETCH_STATUS=0
begin
update t_inventory
set cost=(select cost from inserted where goodsNum=@num)
where goodsNum=@num;
update t_inventory
set price=price+(select cost from inserted where goodsNum=@num)-(select cost from t_inventory where goodsNum=@num)
where goodsNum=@num;
update t_goodsSale
set price=price+(select cost from inserted where goodsNum=@num)-(select cost from t_inventory where goodsNum=@num)
where goodsNum=@num;
fetch next from cur into @num;
end
close cur;
end

结果测试:
测试结果:
原来的库存表t_inventory:
这里写图片描述
原来的销售表t_goodsSale:
这里写图片描述

/*在采购员进货,增加t_goodsBuy之后:*/
insert into t_goodsBuy
values('01','口香糖','03','10','150','盒','绿箭公司','2016/8/23'),
      ('02','方便面','01','10','10','箱','康师傅公司','2016/8/23'),
      ('03','可乐','02','15','12','箱','可口可乐公司','2016/8/23'),
      ('04','饼干','04','11','15','箱','乐事公司','2016/8/23');

t_inventory库存表:
这里写图片描述
t_goodsSale销售表:
这里写图片描述

执行成功的SQL源码:

  1. 建表、创建索引

/*==============================================================*/
/* Table: t_buyer                                               */
/*==============================================================*/
create table t_buyer (
   workerNum            int                  not null,
   workerName           varchar(50)          not null,
)
go

alter table t_buyer
   add constraint PK_T_BUYER primary key nonclustered (workerNum)
go

/*==============================================================*/
/* Index: Index_workerNum                                       */
/*==============================================================*/
create index Index_workerNum on t_buyer (
workerNum ASC
)
go

/*==============================================================*/
/* Index: Index_workerName                                      */
/*==============================================================*/
create index Index_workerName on t_buyer (
workerName  ASC
)
go

/*==============================================================*/
/* Table: t_cashier                                             */
/*==============================================================*/
create table t_cashier (
   workerNum            int                  not null,
   workerName           varchar(50)          not null,
   workTime             varchar(5)           not null
)
go

alter table t_cashier
   add constraint PK_T_CASHIER primary key nonclustered (workerNum)
go

/*==============================================================*/
/* Index: Index_workerNum                                       */
/*==============================================================*/
create index Index_workerNum on t_cashier (
workerNum ASC
)
go

/*==============================================================*/
/* Index: Index_workerTime                                      */
/*==============================================================*/
create index Index_workerTime on t_cashier (
workTime ASC
)
go

/*==============================================================*/
/* Table: t_goodsBuy                                            */
/*==============================================================*/
drop  table t_goodsBuy 
create table t_goodsBuy (
   goodsNum             int                  not null,
   goodsName            varchar(50)          not null,
   workerNum            int                  not null,
   cost                 int                  not null,
   amount               int                  not null,
   units                varchar(50)          not null,
   suppler              varchar(50)          not null,
   date                 varchar(50)          not null
)
go

alter table t_goodsBuy
   add constraint PK_T_GOODSBUY primary key nonclustered ()
go

/*==============================================================*/
/* Index: Index_goodsName                                       */
/*==============================================================*/
create index Index_goodsName on t_goodsBuy (
goodsName ASC
)
go

/*==============================================================*/
/* Index: Index_date                                            */
/*==============================================================*/
create index Index_date on t_goodsBuy (
date ASC
)
go

/*==============================================================*/
/* Index: Index_wokerNum                                        */
/*==============================================================*/
create index Index_wokerNum on t_goodsBuy (
workerNum ASC
)
go



/*==============================================================*/
/* Table: t_goodsOn                                             */
/*==============================================================*/
create table t_goodsOn (
   goodsNum             int                  not null,
   goodsName            varchar(50)          not null,
   cost                 int                  not null,
   prcie                int                  not null,
   amount               int                  not null,
   units                varchar(50)          not null,
   remark               varchar(300)         null,
   workerNum            int                  not null
)
go

alter table t_goodsOn
   add constraint PK_T_GOODSON primary key nonclustered (goodsNum, workerNum)
go

/*==============================================================*/
/* Index: Index_amount                                          */
/*==============================================================*/
create index Index_amount on t_goodsOn (
amount ASC
)
go

/*==============================================================*/
/* Table: t_goodsOnOut                                          */
/*==============================================================*/
create table t_goodsOnOut (
   workerNum            int                  not null,
   goodsNum             int                  not null,
   goodsName            varchar(50)           not null,
   amount               int                  not null
)
go

alter table t_goodsOnOut
   add constraint PK_T_GOODSONOUT primary key nonclustered (workerNum, goodsNum, t_g_workerNum)
go

/*==============================================================*/
/* Index: Index_workerNum                                       */
/*==============================================================*/
create index Index_workerNum on t_goodsOnOut (
workerNum ASC
)
go

/*==============================================================*/
/* Index: Index_goodsNum                                        */
/*==============================================================*/
create index Index_goodsNum on t_goodsOnOut (
goodsNum ASC
)
go

/*==============================================================*/
/* Table: t_goodsSale                                           */
/*==============================================================*/
drop table t_goodsSale
create table t_goodsSale (
   workerNum            int                  not null,
   goodsNum             int                  not null,
   goodsName            varchar(50)          not null,
   prcie                int                  not null,
   amount               int                  not null,
   units                varchar(50)          not null
)
go

alter table t_goodsSale
   add constraint PK_T_GOODSSALE primary key nonclustered (goodsNum)
go

/*==============================================================*/
/* Index: Index_workerNum                                       */
/*==============================================================*/
create index Index_workerNum on t_goodsSale (
workerNum ASC
)
go

/*==============================================================*/
/* Index: Index_profit                                          */
/*==============================================================*/
--create index Index_profit on t_goodsSale (
--profit ASC
--)
--go

/*==============================================================*/
/* Index: Index_amount                                          */
/*==============================================================*/
create index Index_amount on t_goodsSale (
amount ASC
)
go

/*==============================================================*/
/* Table: t_goosClass                                           */
/*==============================================================*/
drop table t_goodsClass
create table t_goodsClass (
   classNum             int                  not null,
   className            varchar(50)          not null,
   goodsNum             int                  not null,
    goodsName            varchar(50)          not null,
   workerNum            int                  not null

)
go

alter table t_goodsClass
   add constraint PK_T_GOOSCLASS primary key nonclustered (goodsNum)
go

/*==============================================================*/
/* Index: Index_goodsName                                       */
/*==============================================================*/
create index Index_goodsName on t_goodsClass (
goodsName ASC
)
go

/*==============================================================*/
/* Index: Index_className                                       */
/*==============================================================*/
create index Index_className on t_goodsClass (
className ASC
)
go

/*==============================================================*/
/* Table: t_inventory                                           */
/*==============================================================*/
create table t_inventory (
   goodsNum             int                  not null,
   goodsName            varchar(50)          not null,
   className            varchar(10)             not null,
   amount               int                  not null,
   cost                 int                  not null,
   prcie                int                  not null,
   units                varchar(50)          not null,
   remark               varchar(300)         null,
)
go

alter table t_inventory
   add constraint PK_T_INVENTORY primary key nonclustered (goodsNum, workerNum)
go

/*==============================================================*/
/* Index: Index_className                                     */
/*==============================================================*/
create index Index_className on t_inventory (
className ASC
)
go

/*==============================================================*/
/* Index: Index_amount                                          */
/*==============================================================*/
create index Index_amount on t_inventory (
amount ASC
)
go

/*==============================================================*/
/* Table: t_manager                                             */
/*==============================================================*/
create table t_manager (
   workerNum            int                  not null,
   workerName           varchar(50)          not null
)
go

alter table t_manager
   add constraint PK_T_MANAGER primary key nonclustered (workerNum)
go

/*==============================================================*/
/* Index: Index_workerNum                                       */
/*==============================================================*/
create index Index_workerNum on t_manager (
workerNum ASC
)
go

/*==============================================================*/
/* Index: Index_workerName                                      */
/*==============================================================*/
create index Index_workerName on t_manager (
workerName ASC
)
go

/*==============================================================*/
/* Table: t_tallyClerk                                          */
/*==============================================================*/
create table t_tallyClerk (
   workerNum            int                  not null,
   workerName           varchar(50)          not null
)
go

alter table t_tallyClerk
   add constraint PK_T_TALLYCLERK primary key nonclustered (workerNum)
go

/*==============================================================*/
/* Index: Index_workerNum                                       */
/*==============================================================*/
create index Index_workerNum on t_tallyClerk (
workerNum ASC
)
go

/*==============================================================*/
/* Index: Index_workerName                                      */
/*==============================================================*/
create index Index_workerName on t_tallyClerk (
workerName  ASC
)
go

/*==============================================================*/
/* Table: t_user                                                */
/*==============================================================*/
drop table t_user
create table t_user (
   workerNum            int                  not null,
   workerName           varchar(50)          not null,
   workerSex            varchar(5) check(workerSex in('男','女'))  not null,
   workerAge            int check(workerAge>=18 and workerAge<=60) not null,
   workTime             varchar(5)           not null,
   job                  varchar(50) check(job in('采购员','收银员','理货员','经理')) not null,
   salary               int                  not null
)
go

alter table t_user
   add constraint PK_T_USER primary key nonclustered (workerNum)
go

/*==============================================================*/
/* Index: Index_workerNum                                       */
/*==============================================================*/
create index Index_workerNum on t_user (
workerNum ASC
)
go

/*==============================================================*/
/* Index: Index_workerName                                      */
/*==============================================================*/
create index Index_salary on t_user (
salary DESC
)
go
  1. 创建视图

说明:视图的作用包括能够简化数据的操作、提供数据库的安全性等等,所以因为需要适时查看上架商品数量、库存数量,以及时补足,同时,查看销售量靠前的商品,优化销售方案等原因,设计了以下三个视图。

/*==============================================================*/
/* View: View_goodsOnAmount 查询上架商品数量视图                */
/*==============================================================*/
create view lihuoyuan.View_goodsOnAmount as
select
goodsNum,
goodsName,
amount
from
t_goodsOn
with check option
go

/*==============================================================*/
/* View: View_goodsSale  查询商品销售数量视图                   */
/*==============================================================*/
create view View_goodsSale as
select
goodsNum,
goodsName,
amount
from
t_goodsSale
go

/*==============================================================*/
/* View: View_inventoryAmount  查询商品库存量视图               */
/*==============================================================*/
create view caigouyuan.View_inventoryAmount as
select
goodsNum,
goodsName,
amount
from
t_inventory
with check option
go


  • 33
    点赞
  • 214
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
商品:商品编号、商品名称、商品单价、生产日期、保质期、商品重量、商品规格 供应商:应商名称、供应商地址、供应商帐号、供应商传真、供应商电话、交货日期、订单号 进销存:库存号、现有库存、最高库存、最低库存、盈亏数量、联系人 (1)针对商店进销存管理系统,分别对采购部门、销售部门和库存保管部门进行详细的调研和分析,总结出如下的需求信息:商品按类管理,所以需要有一商品类型信息。如果一个商品类型存在商品,或存在下级商品类型,则该类型不可删除。需要记录供应商品信息。在涉及商品数量的地方,需要知道商品的库存地方。商品销售信息单中要包含登记商品销售数量、单价等信息。在进货信息中要包含商品供应商等信息。商品报损要有报损原因。进货、销售、报损操作要有相应信息管理员。只有管理员登录之后才可以使用系统。默认的管理员不可以删除。进货、销售、库存、报损信息都要可以添加、修改、删除、分类查找。当进行进货、销售和报损操作后,能相应更新库存。 (2)经上述系统功能分析和需求总结,考虑到将来功能的扩展,设计如下的数据项和数据结构:商品类型信息,包括数据项有:商品信息,包括的数据项有:商品编号、商品名称、商品的的生产日期、库存量等。商供应商信息,包括供应商号、供应商名称、联系电话等。进货信息,包括进货商品号、数量、规格、单价等。销售信息,包括销售商品、数量、单价等。报损信息,包括报损商品、数量、原因、登记时间等。员工信息,包括员工号、姓名、职称等
2007级课程设计报告 课题名称:进销存管理系统(盘点管理管理子系统) 专 业: 班 级: 学 号: 姓 名: 指导教师: 年 月 目录 1. 系统概述…………………………………………………………1 2. 系统分析………………………………………………………2-6 2.1需求分析……………………………………………… 2.2业务流程图……………………………………………… 2.3数据流程图……………………………………………… 2.4数据词典……………………………………………… 3. 系统设计………………………………………………6----32 3.1模块结构设计……………………………………………… 3.2 数据库概念设计……………………………………………… 3.3 数据库逻辑设计……………………………………………… 3.4 输出设计……………………………………………… 3.5 输入设计……………………………………………… 3.6 代码设计……………………………………………… 4.结语………………………………………………33 1.系统概述 现代科技技术突飞猛进,在不同的领域要求各异,以前对库存盘点的统计都是手写登记 ,纸制查看,这样很容易发生错误,导致企事业失去他们所需要的信息,而且会产生错 误信息误导决策,现在为了方便决策者了解到更加确切的信息和资料,所以开发这样的 系统方便决策者查询信息及网上浏览,使各方面的信息都能够正确及时。 系统的功能是将该企业的所有库存盘点信息进行电子统计,根据不同的需求建立各种 的报表,便于企事业在网上查询库存的各方面的信息情况,方便决策者了解市场,也能够方 便管理者对库存盘点的信息进行不同的统计。 库存盘点管理管理子系统主要实现的是库存盘点信息的录入,修改,查询以及盘点信 息的打印等功能,为此,若要实现各方面的需求,系统的数据必须具有高度的完整性和 准确性,这就要求系统的高度安全性,可维护性,可靠性及灵活性。 比如库存管理系统的管理,管理员在录入商品的库存情况的时候或是数据库出现异常 而产生差错,可能会影响决策者从网上查询这些商品的库存情况,这就要求系统具有高 度的安全性,可维护性和可靠性;灵活性指的是系统要具有强大的功能以适应不同层次 的客户不同的需求。另外,系统的操作界面要求简便,通俗,以便于操作。 用户对系统的信用,如果因为一次的错误就会导致一连串的信息错误,所以保证信息 的可靠性十分必须的,这样才能使系统得到用户的信赖和支持。这样的系统需要保证可 靠性,避免给决策者提供虚假的信息,更确保各部门通过浏览该系统,进行相应的需求操作 。 因此,随着技术发展,企业采用库存盘点信息化已成为趋势及必然。 2.系统分析 2.1需求分析 2.1.1需求分析 本系统通过简单的数据库的操作,实现企事业单位的库存信息的管理。库存盘点管理 管理子系统是一个小型的信息管理系统数据库采用SQL Server 2005。使用户和项目人员明确系统的功能、应用范围。 本系统具有以下功能: 1:实现库存盘点管理的信息化管理。 2:实现库存盘点管理的基础要求,如信息添加,查看及删除。操作方便简单,且数据稳 定性强。 3:方便的库存信息查询功能,支持多条件查询。 4:数据计算自动完成,尽量减少人工干预。 5:强大的报表打印功能。 2.1.2开发及运行环境 1. 硬件环境:CPU:C 1.7G以上,内存在256M以上。 2. 软件环境:Windows XP操作系统,Microsoft SQL Servers数据库系统。软件编程使用Microsoft Visual Basic 6.0 中文版。 1 2.1.3程序流程 本库存盘点管理管理子系统使用如下的流程进行登陆以及其他的操作: 开始界面是始于登陆界面"登录(登录.frm)",当用户键入用户名和密码的时候,系 统自动到所对应的数据库"用户信息表"中进行用户验证。如果输入正确则进入系统主界 面,就可以进入到主操作菜单窗体"系统(系统.frm)"中进行操作。在主操作菜单窗体"系 统(系统.frm)"中,用户可以对数据库中的商品信息、供应商信息及客户信息等基本信息 进行包括:添加,查询,修改等操作,并能够进行入库管理,出库管理及库存盘点。此 外,可在"清单报表管理窗口"中进行相应的报表打印。 主界面入下图所示: 2.2业务流程图 库存盘点流程如下: 2.3数据流程图 2.4数据字典 4.1.数据元素条目 "  "  "数据元素条目 "  "  "  " "  " " "总编号: "1-100 "  " "  " " "编 号: "100 "  " "名称: "库存单编号 " "编码说明: "  " "别名: "kcdb " "** ** "** "  " "说明: "库存单编码 " " " "

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值