第一范文网 - 专业文章范例文档资料分享平台

旅行社数据库系统

来源:用户分享 时间:2025/6/7 23:10:12 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

内蒙古科技大学课程设计说明书

3.3创建约束

3.3.1 创建Check约束

alter table tourist –-check约束,只能为男女 add constraint CK_tourist_sex check(tourist_sex='男' or tourist_sex='女'); alter table staff add constraint CK_staff_sex check(staff_sex='男' or staff_sex='女'); alter table tourist –-check约束,身份证号不能大于18位 add constraint CK_tourist_num check(tourist_num<999999999999999999); alter table hotel –-check约束,星级不能大于五位数 add constraint CK_hotel_star check(hotel_star<99999);

3.3.2 创建唯一约束

alter table tour –-唯一约束,团名称不能重复 add constraint UQ_group_name UNIQUE(group_name); 21

内蒙古科技大学课程设计说明书

3.3.3 创建外键

alter table tour add constraint route_id foreign key (route_id) references route(route_id); add constraint staff2_id foreign key (staff2_id) references staff(staff_id); alter table tour alter table hotel add constraint tourist_id foreign key (tourist_id) references tourist(tourist_id); alter table route add constraint group_id foreign key (group_id) references tour(group_id); alter table serve add alter table serve add constraint staff_id foreign key (staff_id) references staff(staff_id); constraint tourist1_id foreign key (tourist1_id) references tourist(tourist_id); alter table ticket add constraint tourist2_id foreign key (tourist2_id) references tourist(tourist_id); alter table tourist constraint group1_id foreign key (group1_id) references tour(group_id); alter table tourist add add constraint staff1_id foreign key (staff1_id) references staff(staff_id);

3.4 创建视图

3.4.1 单表视图

22

内蒙古科技大学课程设计说明书

创建名为view_tourist的单表视图

[travel agency] usego create view view_tourist as select tourist.tourist_id,tourist.tourist_name,tourist.tourist_num,tourist.tourist_address FROM tourist Go

3.4.2 多表视图

创建名为view_tr的多表视图

[travel agency] usego create view view_tr as select tour.group_id,group_name,group_person,route.route_id,route_name FROM tour,route; Go 3.5 创建存储过程

[travel agency] usego create procedure SelProc –-创建名为SelProc的存储过程 as select * from hotel; use [travel agency] go create procedure Count1Proc –-创建名为CountlProc的存储过程 as select * from route 23

内蒙古科技大学课程设计说明书

第四章 数据库运行与测评

4.1 数据库功能实现

4.1.1数据增加

增加员工编号为160,姓名为王凯,性别为男,电话为1122340,学历为大专,工作经历为自主创业,建立该旅行社;

增加员工编号为161,姓名为赵建华,性别为男,电话为1122341,学历为本科,工作经历为2012年大学毕业,担任旅行社经理秘书。

use [travel agency] values('160','王凯','男','1122340','大专','自主创业,建立该旅行社'), ('161','赵建华','男','1122341','本科','2012年大学毕业,担任旅行社经理秘书'); insert into staff(staff_id,staff_name,staff_sex,staff_tel,staff_academic,staff_work)

4.1.2 查询数据

查询修改后的员工信息:

use [travel agency] select * from staff

24

搜索更多关于: 旅行社数据库系统 的文档
旅行社数据库系统.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c58h0j2ngbp1jxus0i399_6.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top