实验三.docx
《实验三.docx》由会员分享,可在线阅读,更多相关《实验三.docx(9页珍藏版)》请在冰点文库上搜索。
![实验三.docx](https://file1.bingdoc.com/fileroot1/2023-5/7/e07f96bc-62b5-48d3-94ab-3bf7e195838e/e07f96bc-62b5-48d3-94ab-3bf7e195838e1.gif)
实验三
数据库系统实现
实验报告
实验名称:
实验3:
IndexingusingBexperiment
姓名:
王慧洁(2121492)
翟红敏(2121532)
指导老师:
王洪亚
日期:
2012年12月08日
一、实验目的:
IndexadatabaseofstudentrecordsusingB-trees.
二、实验内容:
IndexadatabaseofstudentrecordsusingB-trees.
TherewillbeoneindexfilesasthedatabasewillbeindexedbystudentID.Aseparatedatabasefilewillcontaintheactualstudentrecords.Theprogramwilltaketwoinputfiles:
adatafileandacommandfile.Thedatafileisatextfilecontainingstudentrecordsfromwhichthedatabaseanditsindexeswillbeinitiallybuilt.Thecommandfileisalistofinsertandsearchoperationstobecarriedoutafterthefileshavebeenbuilt.
InputandOutputFormats:
Thedatafilewillconsistofsomenumberoftextlines,onestudentrecordperline.Eachlinewillhave6space-separatedfields:
ID(9digits),lastname(atmost15letters),firstname(atmost15letters),year(1digit),major(atmost4letters),andemailaddress(atmost20characters).
Thecommandfilewillcontainlinesspecifiyingoneoffivekindsofcommands:
findID
add
dumpbyID
SampleInputandOutputFiles:
datafile.txt
000000088PlattJohn0MLjplatt@vt.edu
000000097BrillEric1NLPbrill@vt.edu
000000056DumaisSusan2IRdumais@
000000003ChenZheng1CNzhengc@
000000010ChenMing0ISEmcheng@vt.edu
cmdfile.txt
findID000000097
add000000060ShafferClifford1ALGshaffer@vt.edu
add000000066PlattJenny1UNKplatt@vt.edu
add000000021ChenJian0cSEjchen@vt.edu
dumpbyID
三、实验结果及分析:
1.cmdfile.txt和datafile.txt
2.首先根据datafile.txt中的数据构建b+树,
即:
3.查找记录60和88
4.分别依次插入记录60662221
具体过程为:
插入60:
插入66:
插入22:
插入61:
实验结果:
即:
与分析结果一致。
5.分别依次删除记录1922
具体过程为:
删除19:
删除22:
实验结果为:
即:
与分析结果一致。
四、实验小结:
此次实验结果达到了实验目的和要求,通过此次实验,我真正理解了b+树索引的创建、查找、插入、删除等操作的处理过程,更好的理解了索引的作用。