当前位置: 代码迷 >> SQL >> mini-sql储存结构设计
  详细解决方案

mini-sql储存结构设计

热度:336   发布时间:2016-05-05 15:23:29.0
mini-sql存储结构设计

1. Table文件结构

-----------------------------------------------

Header (512B)

@Table Name (32B)

@File Crc32     (4B)

@Dump Flag   (1B)

@Columns Count (1B = Max 8)

@Table Columns (Max 210B >= 196B = 24B*8 = 24B* @Columns Count)

     @Column Name (16B)

     @Column Data Type   (4B)

     @Column Data Size    (4B)

@Primary Key  (4B)

@Row Size (4B)

@Raw Data Size      (4B)

-----------------------------------------------

@Row Index Table  (2B*n)

          1: @Row_i (2B)

          2: @Row_j

          ...

          n: @Row_k

-----------------------------------------------

@Raw Data (@Row Size* n = @Data Size)

@Row_1 

@Row_2

@Row_3

...

@Row_n

-----------------------------------------------

1.1 创建Table文件

SQL请求 -> mini-sql解析器 -> 创建Table文件

1.2 [email protected]_x

按主键升序或降序插入行, [email protected] Index Table, [email protected][email protected] Data尾部。

1.3 删除一些行

根据列条件约束,给出最佳查找算法,以最小访问存储器的时间为准。

删除完后,不直接重组数据,留下碎片,[email protected] Flag,等系统空闲时再整理,以便快速回应处理结果给应用。

1.4 查询

根据列条件约束,给出最佳查找算法,以最小访问存储器的时间为准。

读出查询的数据,返回给应用。

1.5 删除Table文件

SQL请求 -> mini-sql解析器 -> 删除Table文件

端午节快乐~

thanks&best regards

mars.fu

June 23 2012, Saturday

ShenZhen  Hot

If you have more info to communicate with me for this article, please feel free to

Q-me:270982354 or E-me: [email protected].

 

 

  相关解决方案