freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

公交車路線查詢系統(tǒng)后臺(tái)數(shù)據(jù)庫(kù)設(shè)計(jì)(編輯修改稿)

2025-07-26 20:47 本頁(yè)面
 

【文章內(nèi)容簡(jiǎn)介】 me from @stops)) r2 where = and = and = order by set @count=@count+@@rowcount if(@count=0) begin 查詢乘車乘車路線 insert @result select as StartStop, as Route1, as TransStop, as Route2, as EndStop, + as StopCount from @ss_tab sst, @es_tab est, (select * from RouteT0 where EndStop not in (select name from @stops)) r1, RouteT0 r2 where = and = and = and order by + end select StartStop as 起始站點(diǎn), Route1 as 路線1, TransStop as 中轉(zhuǎn)站點(diǎn), Route2 as 路線2, EndStop as 目的站點(diǎn), StopCount as 總站點(diǎn)數(shù) from @result end公交車路線查詢系統(tǒng)后臺(tái)數(shù)據(jù)庫(kù)設(shè)計(jì)換乘算法改進(jìn)與優(yōu)化在《查詢算法》一文中已經(jīng)實(shí)現(xiàn)了換乘算法,但是,使用存儲(chǔ)過(guò)程InquiryT2查詢從“東圃鎮(zhèn)”到“車陂路口”的乘車路線時(shí),發(fā)現(xiàn)居然用了5分鐘才查找出結(jié)果,這樣的效率顯然不適合實(shí)際應(yīng)用。因此,有必要對(duì)原有的換乘算法進(jìn)行優(yōu)化和改進(jìn)。在本文中,將給出一種改進(jìn)的換乘算法,相比原有的算法,改進(jìn)后的算法功能更強(qiáng),效率更優(yōu)。1. “壓縮”RouteT0假設(shè)RouteT0有以下幾行如下圖所示,當(dāng)查詢S1到S4的二次換乘路線時(shí),將會(huì)產(chǎn)生324=24個(gè)結(jié)果從圖中可以看出,第1段路線中的3條線路的起點(diǎn)和站點(diǎn)都相同(第3段路線也是如此),事實(shí)上,換乘查詢中關(guān)心的是兩個(gè)站點(diǎn)之間有無(wú)線路可通,而不關(guān)心是乘坐什么路線,因此,可以將RouteT0壓縮為:如下圖所示,壓縮后,查詢結(jié)果有原來(lái)的24條合并1組查詢結(jié)果為:那么,為什么要對(duì)視圖RouteT0進(jìn)行壓縮呢,原因如下:(1)RouteT0是原有換乘算法頻繁使用的視圖,因此,RouteT0的數(shù)據(jù)量直接影響到查詢的效率,壓縮RouteT0可以減少RouteT0的數(shù)據(jù)量,加速查詢效率。(2)壓縮RouteT0后,將中轉(zhuǎn)站點(diǎn)相同的路線合并為1組,加速了對(duì)結(jié)果集排序的速度。在數(shù)據(jù)庫(kù)中,將使用GRouteT0來(lái)描述壓縮的RouteT0,由于本文使用的數(shù)據(jù)庫(kù)的關(guān)系圖與《查詢算法》中有所不同,在給出GRouteT0的代碼前,先說(shuō)明一下:主要的改變是Stop_Route使用了整數(shù)型的RouteKey和StopKey引用Route和Stop,而不是用路線名和站點(diǎn)名。GRouteT0定義如下: create view GRouteT0asselect StartStopKey, EndStopKey, min(StopCount) as MinStopCount, max(StopCount) as MaxStopCountfrom RouteT0group by StartStopKey,EndStopKey 注意,視圖GRouteT0不僅有StartStopKey和EndStopKey列,還有MinStopCount列,MinStopCount是指從StartStop到EndStop的最短線路的站點(diǎn)數(shù)。例如:上述RouteT0對(duì)應(yīng)的GRouteT0為:以下是二次換乘查詢的存儲(chǔ)過(guò)程GInquiryT2的代碼,該存儲(chǔ)過(guò)程使用了臨時(shí)表來(lái)提高查詢效率: GInquiryT2/*查詢站點(diǎn)@StartStops到站點(diǎn)@EndStops之間的二次換乘乘車路線,多個(gè)站點(diǎn)用39。/39。分開(kāi),結(jié)果以分組方式給出,如:exec InquiryT2 39。站點(diǎn)1/站點(diǎn)239。,39。站點(diǎn)3/站點(diǎn)439。*/CREATE proc GInquiryT2( @StartStops varchar(2048), @EndStops varchar(2048))asbegin declare @ss_tab table(StopKey int) declare @es_tab table(StopKey int) insert @ss_tab select distinct from (@StartStops,39。/39。) sn,Stop where = insert @es_tab select distinct from (@EndStops,39。/39。) sn,Stop where = if(exists(select top 1 * from @ss_tab sst,@es_tab est where =)) begin raiserror (39。起點(diǎn)集和終點(diǎn)集中含有相同的站點(diǎn)39。,16,1) return end declare @stops table(StopKey int) insert @stops select StopKey from @ss_tab insert @stops select StopKey from @es_tab print 39。====================================================39。 print 39。篩選出第1段乘車路線39。 print 39。39。 set statistics time on 篩選出第1段乘車路線,保存到臨時(shí)表R1中 select * into R1 from GRouteT0 where StartStopKey in (select StopKey from @ss_tab) and EndStopKey not in (Select StopKey from @stops) order by StartStopKey,EndStopKey 在臨時(shí)表R1上創(chuàng)建索引 create index index1 on R1(StartStopKey,EndStopKey) set statistics time off print 39。====================================================39。 print 39。篩選出第3段乘車路線39。 print 39。39。 set statistics time on 篩選出第3段乘車路線,保存到臨時(shí)表R3中 select * into R3 from GRouteT0 where EndStopKey in (select StopKey from @es_tab) and StartStopKey not in (Select StopKey from @stops) order by StartStopKey,EndStopKey 在臨時(shí)表上創(chuàng)建索引 create index index1 on R3(StartStopKey,EndStopKey) set statistics time off print 39。====================================================39。 print 39。篩選出第2段乘車路線39。 print 39。39。 set statistics time on 篩選出第2段乘車路線,保存到臨時(shí)表R2中 select * into R2 from GRouteT0 where StartStopKey in (select EndStopKey from R1) and EndStopKey in (Select StartStopKey from R3) 在臨時(shí)表上創(chuàng)建索引 create clustered index index1 on R2(StartStopKey,EndStopKey) create index index2 on R2(EndStopKey,StartStopKey) set statistics time off print 39。====================================================39。 print 39。二次換乘查詢39。 print 39。39。 set statistics time on 二次換乘查詢 select as 起點(diǎn), (,) as 路線1, as 中轉(zhuǎn)站1, (,) as 路線2, as 中轉(zhuǎn)站2, (,) as 路線3, as 終點(diǎn), MinStopCount from( 查詢出站點(diǎn)數(shù)最少的10組路線 select top 10 as StartStopKey, as TransStopKey1, as TransStopKey2, as EndStopKey, (++) as MinStopCount from R1 r1,R2 r2,R3 r3 where = and = order by (++) asc )res, Stop ss, Stop es, Stop ts1, Stop ts2 where = and = and = and = set statistics time off print 39。====================================================39。end (1) 測(cè)試環(huán)境 測(cè)試數(shù)據(jù):廣州市350條公交車路線 操作系統(tǒng):Window XP SP2 數(shù)據(jù)庫(kù):SQL Serv
點(diǎn)擊復(fù)制文檔內(nèi)容
教學(xué)教案相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖片鄂ICP備17016276號(hào)-1