“数据库系统原理课程设计”总结报告.doc_第1页
“数据库系统原理课程设计”总结报告.doc_第2页
“数据库系统原理课程设计”总结报告.doc_第3页
“数据库系统原理课程设计”总结报告.doc_第4页
“数据库系统原理课程设计”总结报告.doc_第5页
免费预览已结束,剩余46页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

“数据库系统原理课程设计”总结报告 “数据库系统原理课程设计”总结报告学院年级专业学号姓名报告日期成绩“数据库系统原理课程设计”总结报告1、 开发环境 Win7操作系统,Visual C+6.0.2、 DBMS系统架构数据库系统输入用户名及密码退出判断用户名及密码 N Y进入系统输入SQL语句,执行相应的具体操作create index drop table select delete update alter insert intocreate table利用建立的索引进行查询操作利用优化算法进行查询操作3、 DBMS主要功能模块1、实现SQL的建库语句,建立相应的数据库表。2、实现表模式的修改功能:能够为已建立的表添加属性。能够从已建立的表中删除属性。3、实现删除表功能。4、实现创建索引的功能。5、修改表中的数据。6、实现SELECT语句:实现单表上的选择和投影操作。7、建立访问权限,设定用户名及密码。 3.1 SQL语言的词法和语法分析(1)功能介绍基于SQL语句的词法及语法分析。(2)相关理论实现对输入语句的词法及语法分析。(3)算法描述利用SLR1文法对输入的SQL语句进行词法及语法分析(4)程序流程图开始输入语句进行语法分析及词法分析 N Y结束(5)测试用例与实验结果3.2创建数据库及数据操作功能(1)功能介绍1、实现建立数据库表结构的功能。(1)支持整型、符点型、字符型数据。(2)以文件形式保存基本表。2、实现输入数据库记录的功能。3、实现删除数据库记录的功能。4、实现修改数据库记录的功能。5、实现显示数据库结构和内容。6、实现在已有的关系中添加属性的功能;7、实现从已有的关系中删除属性的功能;8、实现删除表的功能。(2)相关理论主要是对文件操作,读文件、写文件的运用,验证输入的语句是否符合相应文法的规范。(3)算法描述创建表源代码如下:/create table a ( name char age int ) string order;*DB order; if ( order = create )string temp,tName,tyTemp,tyName;/ tName 表名 tyTemp 类型 tyName 类型变量int dataNum;*DB temp;if ( temp = table )/create table tablename ( xx xxxx xx xxxx )*DB tName;for (listpairstring, listpairstring,vector :iterator ftName = DBase.begin(); ftName != DBase.end(); +ftName)/判断表是否存在if ( tName = ftName-first )cout 表已存在,请勿重复创建! endl;cout endl;return 0; elsecontinue;if ( order != ( )listpairstring, vector attribute;/属性名+数据vector tyData;/数据*DB temp;if ( temp = ( )*DB tyName;while( tyName != ) )*DB tyTemp;if ( tyTemp != int & tyTemp != char & tyTemp != float & tyTemp != double )cout 数据类型错误! endl;cout tyName;DBase.push_back(make_pair(tName,attribute);/绑定表名+(属性名+数据)cSaveTable tName endl;cout 表 tName 创建成功! endl;cout 数据保存完毕! endl;cout endl;return 0; elsecout Error:缺少符号 endl;cout endl;return 0; elsecout Error:缺少表名! endl;cout temp;if ( temp = into )*DB itName;listpairstring, listpairstring,vector :iterator _itable = DBase.begin();for ( ; _itable != DBase.end(); +_itable )/寻找要插入数据的表名if ( _itable-first = itName )/如果相同*DB temp;if ( temp = values )*DB temp;if ( temp = ( )list pairstring, vector :iterator _itype = _itable-second.begin();for ( ; _itype != _itable-second.end(); +_itype )/循环存入数据*DB ityData;if ( ityData != ) )_itype-second.push_back(ityData);continue; elsebreak;cout 插入数据成功! endl;cout 数据保存完毕! endl;cout endl;return 0; elsecout Error:缺少符号或符号不正确 endl;cout endl;return 0; elsecout Error:缺少关键字values或关键字不正确! endl;cout endl;return 0;break;elsecontinue;cout 无此表用于插入数据!请先创建表! endl;cout endl;return 0;elsecout Error:缺少关键字into或关键字不正确! endl;cout itName;listpairstring, listpairstring,vector :iterator _utable = DBase.begin();list pairstring, vector :iterator _utype = _utable-second.begin();for ( ; _utable != DBase.end(); +_utable )/寻找要更新的表if ( _utable-first = itName )*DB temp;if ( temp = set )*DB ityName; for ( ; _utype != _utable-second.end(); +_utype )/寻找要更新的列if ( _utype-first = ityName )*DB temp;if( temp = = )*DB newValue;*DB temp;if ( temp = where )*DB temp;if ( temp = ityName )*DB temp;if ( temp = = )*DB searchValue;int x = 0;vector :iterator _udataSearch = _utype-second.begin();for (; _udataSearch != _utype-second.end(); +_udataSearch)/寻找要更新的值if ( *_udataSearch = searchValue ) *_udataSearch = newValue;cout 数据更新成功! endl;cout 数据保存完毕! endl;cout endl;return 0;elsex+;break;elsecout 缺少符号或符号不正确! endl;cout endl;return 0; elsecout Error:两次列名称不同! endl;cout endl;return 0;elsecout Error:缺少关键字where或关键字不正确! endl;cout endl;return 0;elsecout Error:缺少符号或符号不正确! endl;cout endl;return 0;elsecontinue;cout Error:此表中无此属性! endl;cout endl;return 0;elsecout Error:缺少关键字set或关键字不正确! endl;cout endl;return 0;elsecontinue;break;cout Error:无此表! endl;cout dtName;listpairstring, listpairstring,vector :iterator _dtable = DBase.begin();for ( ; _dtable != DBase.end(); +_dtable )/寻找要drop的表if ( _dtable-first = dtName )DBase.erase(_dtable);cout 删除表成功! endl;cout 数据保存完毕! endl;cout endl;return 0;cout Error:无此表!无需DROP! endl;cout endl;return 0;添加属性源代码如下:elseif ( order = alert )/alert table tablename add tyName typestring temp,atName,atyName,aType;vector addData;*DB temp;if ( temp = table )*DB atName;listpairstring, listpairstring,vector :iterator _atable = DBase.begin();listpairstring,vector :iterator _fNull = _atable-second.begin();int _once = 1;int _fNull;while ( _once )_fNull = _fNull-second.size();_once = 0;for( ; _atable != DBase.end(); +_atable )/寻找要添加属性的表if ( _atable-first = atName ) *DB temp;if ( temp = add )/添加属性*DB atyName;*DB aType;string _NULL = NULL;for ( int times = 0; times second.push_back(make_pair(atyName,addData);cout 添加属性成功! endl;cout 数据保存完毕! endl;cout atyName;*DB aType;listpairstring,vector :iterator _dType = _atable-second.begin();for ( ; _dType != _atable-second.end(); +_dType )/寻找要删除的属性if ( _dType-first = atyName )_atable-second.erase(_dType);cout 删除属性成功! endl;cout 数据保存完毕! endl;cout endl;return 0; elsecontinue; elsecout Error:缺少关键字add或drop或关键字不正确! endl;cout endl;return 0; elsecontinue; elsecout Error:缺少关键字table或关键字不正确! endl;cout temp;if ( temp = from )*DB dtName;listpairstring , listpairstring, vector :iterator _dtable = DBase.begin();for ( ; _dtable != DBase.end(); + _dtable )if ( _dtable-first = dtName )*DB temp;if ( temp = where )*DB dtyName;listpairstring , vector :iterator _dtype = _dtable-second.begin();for ( ; _dtype != _dtable-second.end(); + _dtype )if ( _dtype-first = dtyName )*DB temp;if ( temp = = )*DB dValue;int numValue = 0;vector:iterator _dvalue = _dtype-second.begin();for ( ; _dvalue != _dtype-second.end(); +_dvalue )if ( *_dvalue = dValue )_dtype-second.erase(_dvalue);break; elsenumValue+;continue;for ( _dtype = _dtable-second.begin(); _dtype != _dtable-second.end(); + _dtype )if ( _dtype-first != dtyName )_dtype-second.erase(_dtype-second.begin()+numValue);continue; elsecontinue;cout 删除行数据成功! endl;cout 数据保存成功! endl;cout endl;return 0; elsecout Error:缺少符号=或符号不正确! endl;cout endl;return 0; elsecontinue; elsecout Error:缺少关键字where或关键字不正确! endl;cout endl;return 0; elsecontinue;cout Error:无此表! endl;cout endl;return 0; elsecout Error:缺少关键字from或关键字不正确! endl;cout styName;if( styName = * )*DB temp;if( temp = from )*DB stName;listpairstring , listpairstring, vector :iterator _stable1 = DBase.begin();for(; _stable1 != DBase.end(); +_stable1 )if ( stName != _stable1-first )continue; elsecout endl;cout 表名: first endl;/cout - endl;listpairstring,vector :iterator _stype = _stable1-second.begin();for (; _stype != _stable1-second.end(); +_stype )cout first ;vector:iterator _stypename = _stype-second.begin();for ( ; _stypename != _stype-second.end(); +_stypename)cout *_stypename ;cout endl;/cout - endl;cout endl;return 0;cout 无此表可查找数据! endl;cout endl;return 0;elsecout 无法查找 endl;cout temp;if ( temp = from )*DB stName;*DB temp; if ( temp != where )/没有wherelistpairstring , listpairstring, vector :iterator _stable2 = DBase.begin();for ( ; _stable2 != DBase.end(); +_stable2 )if ( _stable2-first != stName )continue; elsecout endl;cout 表名: first endl;/cout - endl;listpairstring, vector :iterator _styName = _stable2-second.begin();for ( ; _styName != _stable2-second.end(); +_styName )if ( _styName-first = styName )cout first ;vector:iterator _sData = _styName-second.begin();for ( ; _sData != _styName-second.end(); +_sData )cout *_sData ;cout endl;/cout - endl;cout 查找列成功! endl;cout endl;return 0; elsecontinue;cout 无此列可查找数据! endl;cout filename;path = filename_front + filename + filename_end;*DB temp; if ( temp = on )*DB tName;ofstream IndexTable( path.c_str(), ios:out );listpairstring, listpairstring,vector :iterator _iTable = DBase.begin();for( ; _iTable != DBase.end(); +_iTable )if ( _iTable-first = tName )vector:iterator _iTableData = _iTable-second.begin()-second.begin();int IndexCount = 1;for( ; _iTableData != _iTable-second.begin()-second.end(); +_iTableData, +IndexCount )IndexTable IndexCount *_iTableDat

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论