我的租房网设计与实现

上传人:870****95 文档编号:135252425 上传时间:2020-06-14 格式:DOC 页数:18 大小:438.50KB
返回 下载 相关 举报
我的租房网设计与实现_第1页
第1页 / 共18页
我的租房网设计与实现_第2页
第2页 / 共18页
我的租房网设计与实现_第3页
第3页 / 共18页
我的租房网设计与实现_第4页
第4页 / 共18页
我的租房网设计与实现_第5页
第5页 / 共18页
点击查看更多>>
资源描述

《我的租房网设计与实现》由会员分享,可在线阅读,更多相关《我的租房网设计与实现(18页珍藏版)》请在金锄头文库上搜索。

1、数据库技术与开发项目实训设计报告项目名称:我的租房网姓 名:专 业:指导教师: 完成日期:内蒙古科技大学信息工程学院计算机系数据库技术与应用实验报告姓名学号实验成绩班级实验日期项目号、实验名称实训项目我的租房网实验要求1、完成实训项目我的租房网并完成实训一到实训4中的上机实践内容2、按照项目实训报告相关要求,提交一份电子版项目实训报告实验内容1、实训一:建立数据库结构(1) 创建数据库House使用SSMS向导创建数据库House(2) 建立5张数据表-创建客户信息表sys_usercreate table sys_user(-客户编号,主键标识列UserId int identity(1,1

2、) primary key,-客户姓名,非空UserName varchar(50) not null,-客户密码,至少6个字符UserPwd varchar(50) constraint ck_UserPwd check(len(UserPwd)=6)-创建区县信息表hos_districtuse Housegocreate table hos_district(-区县编号,主键,标识列从1开始,递增值为1DId int identity(1,1) primary key,-区县名称,非空DName varchar(50) not null)-创建街道信息表hos_streetuse Hou

3、segocreate table hos_street(-街道编号,主键,标识列从1开始,递增值为1StreetId int identity(1,1) primary key,-街道名称,非空SName varchar(50) not null,-区县编号,表hos_district的外键SDId int constraint fk_SDId foreign key(SDId) references hos_district(DId)-创建房屋信息表hos_typeuse Housegocreate table hos_type(-房屋类型编号,主键,标识列从1开始,递增值为1HTId in

4、t identity(1,1) primary key,-房屋类型名称,非空HTNamevarchar(50) not null)-创建出租房屋信息表hos_houseuse Housegocreate table hos_house(-出租房屋编号,主键,标识列从1开始,递增值为1HMID int identity(1,1) primary key,-客户编号,非空,外键UserId int not null constraint fk_UserId foreign key(UserId) references sys_user(UserId), -街道编号,非空,外键StreetID in

5、t not null constraint fk_StreetID foreign key(StreetID) references hos_street(StreetID), -房屋类型编号,非空,外键HTId int not null constraint fk_HTId foreign key(HTId) references hos_type(HTId),-月租金,非空,默认值为0,要求大于等于0Price decimal(6,2) not null default(0) constraint ck_Price check(Price=0) ,-标题,非空Topic varchar(5

6、0) not null,-描述,非空Contents varchar(100) not null,-发布时间,非空,默认值为当前日期,要求不大于当前日期HTime datetime not null default(getdate() constraint ck_HTime check(HTime=getdate(),-备注Copy varchar(80)(3) 添加外键约束-给客户信息表中的UserName创建非聚集索引create unique nonclustered index Idx_userNameon sys_user(UserName)withfillfactor=10;-给区

7、县信息表中的DName创建非聚集索引create unique nonclustered index Idx_dNameon hos_district(DName)withfillfactor=10;-给街道信息表中的SName创建非聚集索引create unique nonclustered index Idx_sNameon hos_street(SName)withfillfactor=10;-给房屋信息表中的HTName创建非聚集索引create unique nonclustered index Idx_htNameon hos_type(HTName)withfillfactor=

8、10;分析过程:给客户信息表、区县信息表、街道信息表、房屋信息表中添加非聚集索引来提高查询的速度,对经常使用的UserName、DName、SName、HTName进行查询优化2、实训二:添加测试数据(1) 主表添加测试数据-向客户信息表sys_user添加多条条测试数据insert into sys_uservalues(王雪丽,100000), (严德赛,100001), (王生高,100002), (崔晓宇,100003), (卢一帆,100004), (张英武,100005), (安鹏,100006), (胖哥,100007), (程峰,100008), (马云,100009), (王

9、铮,100010), (刘强东,100011), (雷舒然,100012), (成龙,100013), (武则天,100014), (焦旭鹏,100015), (郑利泽,100016), (罗阳光,100017), (邱国龙,100018), (李小龙,100019)-向区县信息表中添加多条记录insert into hos_districtvalues(洪山区), (武昌区), (青山区), (江汉区), (硚口区)-向街道信息表中添加多条记录 insert into hos_streetvalues(街道口,1), (卓刀泉,1), (广埠屯,1), (石牌岭,1), (积玉桥,2), (

10、杨家园,2), (水果湖,2), (黄鹤楼,2), (红卫路,3), (新沟桥,3), (冶金街,3), (厂前街道,3), (吴家山,4), (北湖街,4), (满春街,4), (新华街,4), (六角亭,5), (汉正街,5), (汉中街,5), (长风街,5)-向房屋信息表中添加多条记录insert into hos_typevalues(两室一厅), (两室两厅), (一室一厅), (三室两厅), (四室两厅), (五室两厅)-建立三张临时表create table #topic(Topic varchar(50) not null,)create table #contents(Co

11、ntents varchar(50) not null,)create table #copy(Copy varchar(50) not null,)-向三张临时表中插入数据insert into #topicvalues(东方花园)insert into #topicvalues(金茂东方公寓)insert into #topicvalues(世贸大酒店)insert into #topicvalues(民航小区)insert into #contentsvalues(全新家具电器)insert into #contentsvalues(简单装修押一付三)insert into #conte

12、ntsvalues(精装修,首出租)insert into #contentsvalues(豪华装修,拎包入住)insert into #copyvalues(环境优雅,学区房)insert into #copyvalues(购物方便)insert into #copyvalues(豪华小区,环境优美)insert into #copyvalues(交通便利,配套完善)执行结果:如图1、图2、图3、图4、图5图1客户信息表图2区县信息表图3街道信息表图4房屋信息表 图5三张临时表(2) 添加批量数据declare begin datetime,end datetimeset begin =ge

13、tdate()-定义局部变量declare topic varchar(50)declare contents varchar(50)declare copy varchar(50)declare userid intdeclare streetid intdeclare htid intdeclare price decimal(6,2)declare htime datetime-向hos_house表中插入10000条数据-使用事物begin transactiondeclare i intset i=0while i100begin -对局部变量进行赋值set topic=(select top 1* from #topic order by newid()set contents=(select top 1* from #contents order by newid()

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 大杂烩/其它

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号