没有合适的资源?快使用搜索试试~ 我知道了~
数据库夏季大程报告1
需积分: 0 0 下载量 13 浏览量
2022-08-03
14:05:56
上传
评论
收藏 1.63MB PDF 举报
温馨提示
![preview](https://dl-preview.csdnimg.cn/86285226/0001-c37bc6dde3c7a7c27f12e6592f0c577e_thumbnail.jpeg)
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
试读
32页
1.1 实现功能分析 1.1.1 总目标: 1.1.2 需求概述 1.2 系统体系结构 1.3 设计语言与运行环境 2.3 Catalog Manager 2.
资源详情
资源评论
资源推荐
![](https://csdnimg.cn/release/download_crawler_static/86285226/bg1.jpg)
MiniSQL
设
计
说
明
书
浙
江
大
学
2018~2019
学
年
春
夏
学
期
《
数
据
库
系
统
》
夏
学
期
大程
报
告
1
总
体
框
架
1.1
实
现
功
能
分
析
1.1.1
总
目
标
:
设计并实现一个精简型单用户SQL引擎 (DBMS) MiniSQL,允许用户通过字符界面输入SQL语句实现表的建立/
删除;索引的建立/删除以及表记录的插入/删除/查找。
1.1.2
需
求
概
述
数
据
类
型
:
只要求支持三种基本数据类型: int , char(n) , float ,其中 char(n) 满足 。
表
定
义
:
一个表最多可以定义 个属性,各属性可以指定是否为 unique ;支持单属性的主键定义。
索
引
的
建
立
和
删
除
:
对于表的主属性自动建立 B+ 树索引,对于声明为 unique 的属性可以通过SQL语句由用户
指定建立/删除 B+ 树索引(因此,所有的 B+ 树索引都是单属性单值的)。
查
找
记
录
:
可以通过指定用 and 连接的多个条件进行查询,支持等值查询和区间查询。
插
入
和
删
除
记
录
:
支持每次一条记录的插入操作;支持每次一条或多条记录的删除操作。
1.2
系
统体
系
结
构
1.3
设
计
语
言
与运
行
环
境
工
具
:
JAVA JDK 10.0.2
集
成
开
发
环
境
:
Win10 IntelliJ IDEA
2
各
模
块
实
现
功
能
![](https://csdnimg.cn/release/download_crawler_static/86285226/bg2.jpg)
2.1 Interpreter
Interpreter 模块直接与用户交互,主要实现以下功能:
程序流程控制,即启动并初始化→【接收命令、处理命令、显示命令结果】循环→退出流程。
接收并解释用户输入的命令,生成命令的内部数据结构表示,同时检查命令的语法正确性和语义正确性,对正
确的命令调用API层提供的函数执行并显示执行结果,对不正确的命令显示错误信息。
2.2 API
API 模块是整个系统的核心,其主要功能为提供执行SQL语句的接口,供 Interpreter 层调用。该接口以
Interpreter 层解释生成的命令内部表示为输入,根据 Catalog Manager 提供的信息确定执行规则,并调用
Record Manager 、 Index Manager 和 Catalog Manager 提供的相应接口进行执行,最后返回执行结果给
Interpreter 模块。
2.3 Catalog Manager
Catalog Manager 负责管理数据库的所有模式信息,包括:
数据库中所有表的定义信息,包括表的名称、表中字段(列)数、主键、定义在该表上的索引。
表中每个字段的定义信息,包括字段类型、是否唯一等。
数据库中所有索引的定义,包括所属表、索引建立在那个字段上等。
Catalog Manager 还必需提供访问及操作上述信息的接口,供 Interpreter 和 API 模块使用。
2.4 Record Manager
Record Manager 负责管理记录表中数据的数据文件。主要功能为实现数据文件的创建与删除(由表的定义与删除引
起)、记录的插入、删除与查找操作,并对外提供相应的接口。其中记录的查找操作要求能够支持不带条件的查找和
带一个条件的查找(包括等值查找、不等值查找和区间查找)。
数据文件由一个或多个数据块组成,块大小应与缓冲区块大小相同。一个块中包含一条至多条记录,为简单起见,只
要求支持定长记录的存储,且不要求支持记录的跨块存储。
2.5 Index Manager
Index Manager 负责 B+ 树索引的实现,实现 B+ 树的创建和删除(由索引的定义与删除引起)、等值查找、插入键
值、删除键值等操作,并对外提供相应的接口。
B+ 树中节点大小应与缓冲区的块大小相同, B+ 树的叉数由节点大小与索引键大小计算得到。
2.6 Buffer Manager
Buffer Manager 负责缓冲区的管理,主要功能有:
根据需要,读取指定的数据到系统缓冲区或将缓冲区中的数据写出到文件
实现缓冲区的替换算法,当缓冲区满时选择合适的页进行替换
记录缓冲区中各页的状态,如是否被修改过等
提供缓冲区页的pin功能,及锁定缓冲区的页,不允许替换出去
为提高磁盘I/O操作的效率,缓冲区与文件系统交互的单位是块,块的大小应为文件系统与磁盘交互单位的整数倍,
一般可定为4KB或8KB。
2.7 DB Files
![](https://csdnimg.cn/release/download_crawler_static/86285226/bg3.jpg)
DB Files 指构成数据库的所有数据文件,主要由记录数据文件、索引数据文件和 Catalog 数据文件组成。
3
内
部
数
据
形
式
及
各
模
块
提
供
的
接
口
3.1
内
部
数
据
存
放
形
式
3.1.1
异
常
处
理
在底层模块中,遇到异常时,会抛出Java系统自带的异常类,如 IllegalArgumentException,
NullPointerException 等,但这不便于统一输出错误信息,因此,我们自定义了 QException 异常类, API 模块
在 catch 到底层模块的异常后,统一抛出 QException ,并在 Interpreter 中进行错误信息的输出。
QException 类定义如下:
status 表示自定义的错误状态码, type 表示错误类型,分为语法错误与运行时错误,对应 ex 中的两个字符串,而
msg 则为具体的错误信息。错误状态码如下:
Syntax Error
public class QException extends Exception {
public int status; //status code
public int type; //exception type: 0 for 'syntax error' and 1 for 'rn time error'
public String msg; //exception message
public static final String[] ex = {"Syntax error ", "Run time error "};
}
1
2
3
4
5
6
![](https://csdnimg.cn/release/download_crawler_static/86285226/bg4.jpg)
状
态
码
错
误
信息
状
态
码
错
误
信息
200 No statement specified 602 Extra parameters in drop table
201 Can't find create object 701 Not specify index name
202 Can't identify ... (create时的名称) 702 Must add keyword 'on' after index name ...
203 Can't find drop object ... 703 Not specify table name
204 Can't identify ... (drop时的名称) 704 Not specify attribute name in table ...
205 Can't identify ... (指令) 705 Error in specify attribute name ...
323 Can not find valid key word after 'show'! 706 Extra parameters in create index
401 Must specify a table name 801 Not specify index name
402 Can't find attribute definition 802 Extra parameters in drop index
403
Can't not find the definition brackets in table
...
250
Can not find key word 'from' or lack of
blank before from!
404 Empty attribute in table ... 901 Must add keyword 'into' after insert
405 Error definition of primary key in table ... 902 Not specify the table name
406 Error definition of primary key in table ... 903 Must add keyword 'into' after insert
407 Redefinition of primary key in table ... 904 Not specify the insert value
408 Incomplete definition in attribute ... 905 Syntax error: Not specify the insert value
409 Redefinition in attribute 906 Must add keyword 'values' after table ...
410 ust specify char length in ... 907 Can't not find the insert brackets in table ...
411 Wrong definition of char length in ... 908 Empty attribute value in insert value
412
The char length in ... dosen't match a int
type or overflow
1001 Extra parameters in quit
413 The char length in ... must be in [1,255] 1101 Extra parameters in sql file execution
414 Error attribute type ... in ... 1103 Can't find the file
415 Error constraint definition in ... 1104 IO exception occurs
416 Not specified primary key in table ...
601 Not specify table name
Runtime Error
![](https://csdnimg.cn/release/download_crawler_static/86285226/bg5.jpg)
状
态
码
错
误
信息
状
态
码
错
误
信息
500 Failed to initialize API! 512 IllegalArgumentException 错误信息
501 Table ... already exist! 513 Failed to delete on table ...
502 Failed to create an index on table ... 514 Table ... doesn't exist!
503 Failed to create table ... 515 IllegalArgumentException 错误信息
504 Table ... doesn't exist! 516 Table ... doesn't exist!
505 Failed to drop table ... 517 IllegalArgumentException 错误信息
506 Failed to create index ... on table ... 518 Failed to select from table ...
507 Failed to drop index ... on table ... 519 Table ... doesn't exist!
508 Table ... doesn't exist! 520 IllegalArgumentException 错误信息
509 IllegalArgumentException 错误信息 521 Table ... doesn't exist!
510 Failed to insert a row on table ... 522 IllegalArgumentException 错误信息
511 Table ... doesn't exist! 909 Attribute number doesn't match
707 Not a unique attribute 910 Duplicate unique key: ...
有些不同状态码的错误信息是一样的 ,这是由于在不同的过程 (insert, delete, select , create, drop 等) 中遇到相同的
问题而抛出的不同的状态码。
3.1.2 CatalogManager
数
据
存储在 table_catalog 和 index_catalog 两个二进制文件中,在创建出catalog实例的时候即解析这两个文件并载
入内存中由于。这两个文件使用频繁并且占用内存并不大,所以由 CatalogManager 单独保管,而不交给
BufferManager 管理。
3.1.3 BufferManager, Block
数
据
结
构
BufferManager 缓冲区主要由 Block 类以及一系列的成员方法进行管理。为了提高I/O效率,每一个 Block 由4096
字节组成,同时,缓冲区中最多能够放置50个 Block ,其数据结构如下:
3.2 Interpreter
实
现
Interperter
总
体
流
程
:
Interpreter 模块直接与用户交互,负责接收并解释用户输入的命令,返回结果信息,实现
程序总体流程控制,其总体设计流程如下:
public static final int BLOCKSIZE = 4096; //4KB for 1 block
private byte[] blockData = new byte[BLOCKSIZE]; //allocate 4KB memory for 1 block
private static final int MAXBLOCKNUM = 50; //maximum block numbers
public static Block[] buffer = new Block[MAXBLOCKNUM]; //buffer
1
2
3
4
5
剩余31页未读,继续阅读
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![avatar](https://profile-avatar.csdnimg.cn/fe36fbe8a6464097bef4d0d8965a214a_weixin_35763513.jpg!1)
方2郭
- 粉丝: 26
- 资源: 324
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
最新资源
- 基于Python的无人载具/无人船上位机控制系统可导入坐标自动巡航,带语音反馈功能+源码解析+开发文档(毕设&课设&项目开发)
- 附件1:赣南科技学院课程设计报告撰写规范.docx
- 编程实战:基于JAVA和SQL的离散数学题库管理系统(源代码+文档+外文翻译)
- 毕设项目:离散数学题库管理系统(JAVA+SQL+源代码+文档+外文翻译)
- 基于STM32F1系列微控制器的四旋翼飞行控制器+无人机自动控制+源码(毕业设计&课程设计&项目开发)
- library_OA.zip
- DS18B20温度传感器开发教程.docx
- 基于python开发的无人机群控与协同作业网络化控制平台+源码+算法(毕业设计&课程设计&项目开发)
- cosmos.opml
- C# yolov8 模型效果验证工具(OnnxRuntime+ByteTrack推理).rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)
评论0