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

正文內(nèi)容

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

2025-07-26 20:47 本頁面
 

【文章內(nèi)容簡介】 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 起始站點, Route1 as 路線1, TransStop as 中轉(zhuǎn)站點, Route2 as 路線2, EndStop as 目的站點, StopCount as 總站點數(shù) from @result end公交車路線查詢系統(tǒng)后臺數(shù)據(jù)庫設(shè)計換乘算法改進與優(yōu)化在《查詢算法》一文中已經(jīng)實現(xiàn)了換乘算法,但是,使用存儲過程InquiryT2查詢從“東圃鎮(zhèn)”到“車陂路口”的乘車路線時,發(fā)現(xiàn)居然用了5分鐘才查找出結(jié)果,這樣的效率顯然不適合實際應(yīng)用。因此,有必要對原有的換乘算法進行優(yōu)化和改進。在本文中,將給出一種改進的換乘算法,相比原有的算法,改進后的算法功能更強,效率更優(yōu)。1. “壓縮”RouteT0假設(shè)RouteT0有以下幾行如下圖所示,當查詢S1到S4的二次換乘路線時,將會產(chǎn)生324=24個結(jié)果從圖中可以看出,第1段路線中的3條線路的起點和站點都相同(第3段路線也是如此),事實上,換乘查詢中關(guān)心的是兩個站點之間有無線路可通,而不關(guān)心是乘坐什么路線,因此,可以將RouteT0壓縮為:如下圖所示,壓縮后,查詢結(jié)果有原來的24條合并1組查詢結(jié)果為:那么,為什么要對視圖RouteT0進行壓縮呢,原因如下:(1)RouteT0是原有換乘算法頻繁使用的視圖,因此,RouteT0的數(shù)據(jù)量直接影響到查詢的效率,壓縮RouteT0可以減少RouteT0的數(shù)據(jù)量,加速查詢效率。(2)壓縮RouteT0后,將中轉(zhuǎn)站點相同的路線合并為1組,加速了對結(jié)果集排序的速度。在數(shù)據(jù)庫中,將使用GRouteT0來描述壓縮的RouteT0,由于本文使用的數(shù)據(jù)庫的關(guān)系圖與《查詢算法》中有所不同,在給出GRouteT0的代碼前,先說明一下:主要的改變是Stop_Route使用了整數(shù)型的RouteKey和StopKey引用Route和Stop,而不是用路線名和站點名。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的最短線路的站點數(shù)。例如:上述RouteT0對應(yīng)的GRouteT0為:以下是二次換乘查詢的存儲過程GInquiryT2的代碼,該存儲過程使用了臨時表來提高查詢效率: GInquiryT2/*查詢站點@StartStops到站點@EndStops之間的二次換乘乘車路線,多個站點用39。/39。分開,結(jié)果以分組方式給出,如:exec InquiryT2 39。站點1/站點239。,39。站點3/站點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。起點集和終點集中含有相同的站點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段乘車路線,保存到臨時表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 在臨時表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段乘車路線,保存到臨時表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 在臨時表上創(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段乘車路線,保存到臨時表R2中 select * into R2 from GRouteT0 where StartStopKey in (select EndStopKey from R1) and EndStopKey in (Select StartStopKey from R3) 在臨時表上創(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 起點, (,) as 路線1, as 中轉(zhuǎn)站1, (,) as 路線2, as 中轉(zhuǎn)站2, (,) as 路線3, as 終點, MinStopCount from( 查詢出站點數(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) 測試環(huán)境 測試數(shù)據(jù):廣州市350條公交車路線 操作系統(tǒng):Window XP SP2 數(shù)據(jù)庫:SQL Serv
點擊復(fù)制文檔內(nèi)容
教學教案相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖片鄂ICP備17016276號-1