教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 精品文档 > 建筑文档 >

数据库课程设计--图书管理系统(4)

来源:网络收集 时间:2026-03-29
导读: 滨海学院数据库课程设计 insert into BD(B_identifier,B_name,B_auther,B_publish) values ('00004','计算机网络','单默','西安电子科技大学出版社') insert into BD(B_identifier,B_name,B_auther,B_publish) valu

滨海学院数据库课程设计

insert into BD(B_identifier,B_name,B_auther,B_publish) values ('00004','计算机网络','单默','西安电子科技大学出版社') insert into BD(B_identifier,B_name,B_auther,B_publish) values ('00005','七龙珠','斯默','电子工业出版社')

(2)供应商信息表(GD表)

insert into GD(provider,address,linkman,telephone)

values ('电子工业出版社','北京市七八街','赵六',15212345674) insert into GD(provider,address,linkman,telephone) values ('清华大学','北京市五六街','王五',15212345673) insert into GD(provider,address,linkman,telephone)

values ('人民邮电出版社','北京市三四街','李四',15212345672) insert into GD(provider,address,linkman,telephone)

values ('西安电子科技大学','北京市一二街','张三',15212345671)

(3)供应信息表(BGD表)

insert into BGD(B_identifier,provider,order_count,order_time,order_price,order_money) values ('00001','电子工业出版社',20,'2009-11-12',20,400)

insert into BGD(B_identifier,provider,order_count,order_time,order_price,order_money) values ('00002','清华大学',20,'2009-11-15',30,600)

insert into BGD(B_identifier,provider,order_count,order_time,order_price,order_money)

15

滨海学院数据库课程设计

values ('00003','人民邮电出版社',20,'2009-11-20',50,1000)

insert into BGD(B_identifier,provider,order_count,order_time,order_price,order_money) values ('00004','西安电子科技大学',20,'2009-11-22',40,800)

insert into BGD(B_identifier,provider,order_count,order_time,order_price,order_money) values ('00005','电子工业出版社',20,'2009-11-23',30,600)

通过上述方式继续输入其他三个表信息,截图如下: (4)客户信息表(CD表)

(5)销售信息表(BCD表)

(6)销售单表(BSD表)

16

滨海学院数据库课程设计

6.2.2运行测试

(1)查询某月书店销售金额及营业总额 查询7月份书店销售金额: select sum(sell_money)as '当月收入' from BCD

where sell_time_mon=7 select sum(sell_money)as'总收入' from BCD

(2)查询某种图书库存数量

查询编号是00002的图书库存数量: select order_count from BGD

where B_identifier='00002'

(3)查询某月销售最好的图书信息

17

滨海学院数据库课程设计

查询7月份销售最好的图书信息:

select BD.B_identifier,B_name,B_auther,B_publish,sell_counts from BD,BSD

where BD.B_identifier=BSD.B_identifier

group by BD.B_identifier,B_name,B_auther,B_publish,sell_counts having max(sell_counts)= (select max(sell_counts) from BSD

group by sell_time_mon having sell_time_mon=7)

(4)按供应商名称查询订购信息

查询供应商名为电子工业出版社的订购信息: select* from BGD

where provider='电子工业出版社'

(5)查询订购次数超过3(包括3)次的客户信息 select CD.C_identifier,C_name,C_sex,C_age from CD,BCD

where CD.C_identifier=BCD.C_identifier group by CD.C_identifier,C_name,C_sex,C_age having count(CD.C_identifier)>=3

18

滨海学院数据库课程设计

7数据库的运行和维护

7.1安全性与完整性

7.1.1安全性

数据库的安全性是指保护数据库以防止非法使用造成的数据泄漏、更改或破坏。 我们可以通过创建服务器登入账号来实现其安全性。如:

创建了一个名为“mch”的登陆账号,其密码为000000,与BS数据库相连 EXEC sp_addLogin 'mch','000000','BS',NULL EXEC sp_adduser 'mch'

为登陆账号“mch”设置一个名为“mch”的数据库用户账号,设置为db_owner角色。

EXEC sp_adduser 'mch','mch','db_owner' 7.1.2完整性

数据库的完整性是之保护数据库中数据的正确性、有效性和相容性,防止错误的数据进入数据库造成无效的操作。而实施数据库完整性的方法有五种:约束、默认值、规则、存储过程和 触发器。

(1)约束

约束是SQL Server自动强制数据库完整性的方式,约束定义了列中允许的取值。 (2)默认值

默认是向用户输入记录时没有指定具体数据的列中自动插入的数据。

(3)规则

规则是数据库对存储在表中的列或用户自定义数据类型中的值的规定和限制。 (4)存储过程

19

…… 此处隐藏:949字,全部文档内容请下载后查看。喜欢就下载吧 ……
数据库课程设计--图书管理系统(4).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wendang/438754.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)