Skip to content

ltylty/SimpleDB

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

从零实现一个数据库。

演示

  1. 运行 FreedomServer 的main方法。
  2. MySQL客户端需要5.7版本。终端中执行 mysql -hlocalhost -P8090 -upay -p123。
  3. 执行sql。目前不支持建表语句。
    -- 查询
    SELECT p.title
    FROM papers p
    WHERE p.title LIKE 'selectivity';
    
    SELECT a.title, d.name
    FROM papers a, authors b, paperauths c, venues d
    WHERE b.name = 'E. F. Codd'
    AND c.authorid = b.id
    AND c.paperid = a.id
    AND a.venueid = d.id;
     
    SELECT a2.name, count(p.id)
    FROM papers p, authors a1, authors a2, paperauths pa1, paperauths pa2
    WHERE a1.name = 'Michael Stonebraker'
    AND pa1.authorid = a1.id 
    AND pa1.paperid = p.id 
    AND pa2.authorid = a2.id 
    AND pa1.paperid = pa2.paperid
    GROUP BY a2.name
    ORDER BY a2.name;
    
    -- 删除和新增
    delete FROM authors where id = 141801;
    select * from authors where id = 141801;
    insert into authors (id,name) values (141801, 'lty');
    select * from authors where id = 141801;
    
    -- 事务
    delete FROM authors where id = 141801;
    set transaction READ WRITE;
    insert into authors (id,name) values (141801, 'lty');
    select * from authors where id = 141801;
    ROLLBACK;
    select * from authors where id = 141801;
           
        

实现过程

  1. 完成数据库作业cs186,也就实现了数据存储层和sql解析优化层,实现细节doc/cs186.org。代码在engine包中。
  2. 加上mysql网络协议层,协议分析doc/protocol.md,协议层借鉴了Freedom。代码在server包中。

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages