Git Product home page Git Product logo

go-sqldb's Introduction

Go SQL DB

中文

"Go SQL DB" is a relational database that supports SQL queries for research purposes. The main goal is to show the basic principles and key design of a relational database to database enthusiasts. Therefore, to easily understand, a lot of tricks but not very rigorous design was adopted, and the amount of code was controlled at about 2000 lines.

Features

  1. Pure Golang implementation, does not rely on any third-party packages. Goconvey was only introduced in unit tests
  2. Unit test coverage ≈ 73.5%

Storage Engine

  1. Special Thanks to Let's Build a Simple Database
  2. Data retrieval structure based on B-Tree
  3. Disk persistence engine based on 4KB paging
  4. Close to POD (Plain Old Data) speed serialization & deserialization

SQL Parser

  1. Tokenizer is implemented based on text/scanner
  2. Support simple SELECT, INSERT syntax
    1. SELECT supports WHERE of numeric type
    2. Support LIMIT, but not support ORDER BY temporarily
  3. If you want to know how the SQL Parser that can be used in the production environment is implemented, please refer to the SQL Parser that I stripped from CockroachDB and supports the SQL-2011 standard

Execution Planner

  1. Select Implementation based on Volcano Model
  2. HTTP-based query and insert interface

Known Issues

  1. No DDL is implemented for the time being, only a fixed Schema
    struct Row {
        Id uint32
        Sex byte
        Age uint8
        Username [32]byte
        Email [128]byte
        Phone [64]byte
    }
  2. For limited support for SQL syntax, see Test Cases
  3. Tokenizer is based on a clever implementation of the Golang language itself, there will be problems with the support of special characters in some strings, which can be solved by quoting strings with "

How to run

  1. Run

    go run . test.db
  2. INSERT

    Execute INSERT INTO table (id, username, email) VALUES (10, auxten, "auxtenwpc_gmailcom")

    BY accessing: http://localhost:8080/exec?q=INSERT%20INTO%20table%20(id,%20username,%20email)%20VALUES%20(10,%20auxten,%20%22auxtenwpc_gmailcom%22)

  3. SELECT

    Query SELECT * FROM table WHERE id > 3 LIMIT 10

    BY accessing: http://localhost:8080/query?q=SELECT%20*%20FROM%20table%20WHERE%20id%20%3E%203%20LIMIT%2010

Thanks

  1. SQL-2011 SQL Parser
  2. Marshal/Unmarshal Code generation
  3. Document-oriented, embedded SQL database: genji
  4. CockroachDB
  5. Let's Build a Simple Database

go-sqldb's People

Contributors

auxten avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.