for delete
as
print '请在仓库中删除此手机'
在仓库信息表上建立触发器 create trigger tri_S_update on 仓库信息表 for update as if (select area from 仓库信息表 where sid = 'S001') = 0 print '此货架已满'
create trigger tri_S_update2 on 仓库信息表 for update as if (select area from 仓库信息表
where sid = 'S002') =0 print '此货架已满'
create trigger tri_S_update3 on 仓库信息表 for update as if (select area from 仓库信息表 where sid = 'S003') =0 print '此货架已满' 在库存手机表上建立触发器
create trigger tri_update_Stele
11
on 库存手机表 for update
as
if (select snum from 库存手机表 where tid = 'A001')<10 print '存货不足 请及时进货'
create trigger tri_update_Stele2 on 库存手机表 for
update
as if (select snum
from 库存手机表 where tid = 'A002')<10 print '存货不足 请及时进货'
create trigger tri_update_Stele3 on 库存手机表 for
update
as if (select snum
from 库存手机表 where tid = 'A003')<10 print '存货不足 请及时进货'
(5) 建立储存过程
12
按手机名查询的存储过程 create procedure telefind @telename char(30) as select * from 手机信息表
where Tname = @telename
统计手机存储过程 create
Sum_money as
select 手机信息表.Tname,Tcolor,Buynum,Snum,Tprice from 手机信息表,库存手机表,进货单
where 手机信息表.tid = 库存手机表.tid and 手机信息表.tid = 进货单.tid
顾客查询手机存储过程 create procedure CteleInfo as select Tname,Tcolor,Tprice from 手机信息表
供应商信息存储过程 create procedure Spp @Pno char(15) as select *
from 供应商信息表
13
procedure
where PID=@Pno 手机信息表插入:
create procedure Up_TeleInfo
@TI char(15),@TN char(15),@TC char(15),@TPri int,@Sno char(15),@PI char(15) as
insert into 手机信息表
values (@TI,@TN,@TC,@TPri,@Sno,@PI)
数据库测试
对该手机销售管理系统进行测试验证每个功能是否符合要求具体的测试如下 1 通过视图查看各个基本表和视图中的数据 2 触发器的测试 3 储存过程的测试
14
手机关系模式
名称 Tname Tcolor TPrice TID SID PID
简述 手机品牌型号 手机颜色 手机价格 手机编号 仓库货架编号 供应商编号
类型宽度 Char(30) Char15
Int Char15 Char(15) Char15
说明
仓库关系模式
SID Area ADID
仓库货架编号 仓库剩余面积 管理员编号
Char(15) Float10 Char(10)
供应商关系模式
PID PName PAddr PTele
供应商编号 供应商姓名 供应商地址 联系电话
Char(15) Char(20) Char(30) Char(11)
BuyTime BNum BuyID Tname
购买时间 购买数量 购机单的编号 手机品牌型号 手机颜色 手机价格
购机单关系模式
DtateTime Int Char(15) Char(30) Char(15)
int
Tcolor Tprice
15