1.课程设计目的 |
(1)培养学生运用所学课程《数据库原理及应用》的理论知识和技能,深入理解《数据库原理及应用》课程相关的理论知识,学会分析实际问题的能力。 (2)培养学生掌握用《数据库原理及应用》的知识设计计算机应用课题的思想和方法。 (3)培养学生调查研究、查阅技术文献、资料、手册以及编写技术文献的能力。 (4)通过课程课程设计的训练,要求学生在教师的指导下,独立完成大作业要求的相关内容,包括: ① 通过调查研究和运用Internet,收集和调查有关资料、最新技术信息。 ② 基本掌握撰写小论文的基本步骤和写作方法。 ③ 根据课题的要求基本理解和掌握E-R图的设计方法和关系模式的转换。 ④ 根据课题的要求基本理解和掌握数据流图(DFD)和数据字典(DD)的设计方法。 ⑤ 根据E-R图生成数据库表。 ⑥ 数据库完整性、安全性保证措施 ⑦ 数据库实施维护计划 |
2.课程设计任务与要求: |
(1)每个学生从下面50个题目中任选一个作为课程设计,调查分析一个具体的或模拟的实例。同一个班中的同学不允许选择相同的题目。选好题目后发给班长或学习汇总,产生选题冲突时,由班长/委员协调解决; (2)描述该实例的业务信息和管理工作的要求,画出业务流图、数据流图,确定数据字典; (3)列出实体、联系; (4)指出实体和联系的属性; (5)画出E-R图; (6)将E-R图转换成关系模式,并注明主码和外码; (7)创建数据库; (8)根据题目的要求写查询、存储过程、触发器等; (9)系统实现。 |
3.课程设计说明书 |
3.1 需求分析 3.1.1 应用系统背景 通过对现流行在市场的软件的调查发现,现在市场上软件多是针对大客户。开发的过程比较复杂、昂贵,也不容易操作与维护,不能被广大的小企业或是超市、商店等使用。所以抓住市场的这个空白区,去开发商店的进销存管理系统。 3.1.2 组织结构图 3.1.3 需求分析过程 (1)商品管理:实现对商品信息的插入、查询、修改、删除等功能 (2)员工管理:实现对员工信息的插入、查询、修改、删除等功能 (3)库存管理:实现对商品库存信息的插入、查询、修改、删除等功能 (4)入库管理:实现对入库信息的插入、查询、修改、删除以及支出信息的记录等功能 (5)出库管理:实现对出库信息的插入、查询、修改、删除以及收入信息的记录等功能 (6)转仓管理:实现对商品仓库信息转移的插入、查询、修改、删除等功能 (7)仓库管理:实现对仓库信息的插入、查询、修改、删除等功能 (8)供应商管理:实现对供应商信息的插入、查询、修改、删除等功能 3.1.4 数据流图 3.1.5 数据字典 3.2 概念结构设计 3.2.1 基本原则 (1)各表实现实现CRUD功能 (2)保证数据库完整性 3.2.2 E-R模型 (1)局部ER图 (2)全局ER图 3.3 逻辑结构设计
实现商品类别、供货商、业务员信息管理; 实现商品信息、仓库信息管理、仓库商品管理; 实现商品验收入库、商品销售出库管理,入库和出库时自动修改对应商品的总库存和分库库存量(用触发器实现),另外验收或销售时一单可以验收或销售多种商品; 实现转仓管理,转仓时自动修改转出仓库和转入仓库对应商品的数量(用触发器实现); 创建存储过程统计指定时间段内各种商品的进货数量和销售数量; 设商品的单位只能是‘只’、‘件’、‘箱’,创建规则进行限制; 创建表间关系。 3.3.2 E-R图向关系模型的转换 3.4 物理结构设计 3.4.1 基本分析 shop_change(goods_id, goods_name, from_whse_id, to_whse_id, trf_num, trf_date, staff_id) shop_goods(goods_id, goods_name, goods_cat, goods_unit, goods_mfd, goods_exp, goods_pd, goods_pprice, goods_stock, goods_insuf, goods_mature) shop_goodswhse(goods_id, goods_name, whse_id, whse_name, stock) shop_instore(supplier_id, supplier_name, goods_id, goods_name, whse_id, in_num, in_price, instore_date, staff_id) shop_outstore(goods_id, goods_name, whse_id, outstore_num, outstore_price, outstore_date, staff_id) shop_staff(staff_id, staff_name, staff_bd, staff_phone, staff_address,staff_sex) shop_storage(whse_id, whse_name, whse_phone, whse_address) shop_supplier(supplier_id, supplier_name, supplier_phone, supplier_address) 3.3.2 物理结构 3.5 界面设计与实现 3.5.1 登陆界面 3.5.2 修改子操作界面 3.5.3 查询子操作界面 3.6 数据库代码 3.6.1 触发器 转仓: begin set new.goods_name = (select goods_name from shop_goods where goods_id = new.goods_id); set new.trf_date = now(); update shop_goodswhse set stock = stock + new.trf_num where goods_id = new.goods_id and whse_id = new.to_whse_id; update shop_goodswhse set stock = stock - new.trf_num where goods_id = new.goods_id and whse_id = new.from_whse_id; end 商品: begin if new.goods_stock > 50 then set new.goods_insuf = '商品库存充足'; else set new.goods_insuf = '商品库存不足'; end if;
if now() > new.goods_exp then set new.goods_mature = '商品临期'; else set new.goods_mature = '商品未临期'; end if; end 库存: begin set new.goods_name = (select goods_name from shop_goods where goods_id = new.goods_id); set new.whse_name = (select whse_name from shop_storage where whse_id = new.whse_id); end BEGIN UPDATE shop_goods set goods_stock=goods_stock+(new.stock-old.stock) WHERE goods_id=new.goods_id; END 入库: begin set new.goods_name = (select goods_name from shop_goods where goods_id = new.goods_id); set new.supplier_name = (select supplier_name from shop_supplier where supplier_id = new.supplier_id); set new.instore_date = now(); update shop_goods set goods_pd = now() where goods_id = new.goods_id; update shop_goods set goods_pprice = new.in_price where goods_id = new.goods_id; UPDATE shop_goods set goods_stock = goods_stock+new.in_num where goods_id = new.goods_id; if (select goods_id from shop_goodswhse where goods_id = new.goods_id and whse_id = new.whse_id) is null then insert into shop_goodswhse(goods_id, whse_id, stock) VALUES(new.goods_id, new.whse_id, new.in_num); else update shop_goodswhse set stock = stock + new.in_num where goods_id = new.goods_id and whse_id = new.whse_id; end if; end 出库: begin set new.goods_name = (select goods_name from shop_goods where goods_id = new.goods_id); set new.outstore_price = (select goods_pprice from shop_goods where goods_id = new.goods_id) *2; set @selected_whse_id = (select whse_id from shop_goodswhse where goods_id = new.goods_id and stock > new.outstore_num limit 1); update shop_goodswhse set stock = stock - new.outstore_num where goods_id = new.goods_id and whse_id = @selected_whse_id; end 3.6.2 存储过程 CREATE DEFINER=`root`@`localhost` PROCEDURE `gagaga`( in begindate date, in enddate date ) begin select shop_goods.goods_id as '商品编号', sum(in_num) as '进货量', sum(outstore_num) as '销售量' from shop_goods, shop_instore, shop_outstore where instore_date >= begindate and instore_date <= enddate and outstore_date >= begindate and outstore_date <= enddate and shop_goods.goods_id = shop_instore.goods_id and shop_goods.goods_id = shop_outstore.goods_id group by shop_goods.goods_id; end 3.6.3 其余代码(部分代码,需要完整代码联系QQ:1115395894) /* Navicat Premium Data Transfer Source Server : mysql Source Server Type : MySQL Source Server Version : 50719 (5.7.19-log) Source Host : localhost:3306 Source Schema : ruoyi_new Target Server Type : MySQL Target Server Version : 50719 (5.7.19-log) File Encoding : 65001 Date: 17/11/2022 20:04:42 */ SET NAMES utf8mb4; SET FOREIGN_KEY_CHECKS = 0; -- ---------------------------- -- Table structure for shop_change -- ---------------------------- DROP TABLE IF EXISTS `shop_change`; CREATE TABLE `shop_change` ( `goods_id` int(11) NOT NULL COMMENT '商品编号', `goods_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '商品名称', `from_whse_id` int(11) NOT NULL COMMENT '转出仓库编号', `to_whse_id` int(11) NOT NULL COMMENT '转入仓库编号', `trf_num` int(11) NOT NULL COMMENT '转移商品数量', `trf_date` date NULL DEFAULT NULL COMMENT '转移时间', `staff_id` int(11) NOT NULL COMMENT '操作员工编号', INDEX `f16`(`goods_id`) USING BTREE, INDEX `f17`(`from_whse_id`) USING BTREE, INDEX `f18`(`to_whse_id`) USING BTREE, INDEX `f40`(`staff_id`) USING BTREE, CONSTRAINT `f16` FOREIGN KEY (`goods_id`) REFERENCES `shop_goods` (`goods_id`) ON DELETE RESTRICT ON UPDATE RESTRICT, CONSTRAINT `f17` FOREIGN KEY (`from_whse_id`) REFERENCES `shop_storage` (`whse_id`) ON DELETE RESTRICT ON UPDATE RESTRICT, CONSTRAINT `f18` FOREIGN KEY (`to_whse_id`) REFERENCES `shop_storage` (`whse_id`) ON DELETE RESTRICT ON UPDATE RESTRICT, CONSTRAINT `f40` FOREIGN KEY (`staff_id`) REFERENCES `shop_staff` (`staff_id`) ON DELETE RESTRICT ON UPDATE RESTRICT ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '转仓管理' ROW_FORMAT = DYNAMIC; 3.7 总结 |