Home > cl-simpledb

cl-simpledb

Cl-simpledb is a project mainly written in COMMON LISP and SHELL, based on the GPL-2.0 license.

SimpleDB project implemented in Common Lisp, inspired by Java SimpleDB project from Sam Madden @ MIT

+TITLE: SimpleDB Instructions

+AUTHOR: Michael Zeller

+EMAIL: [email protected]

  • Overview

This is a project folder for my attempt to implement some of the phases of the cs222 project in Common Lisp.

  • Progress

  • [X] Phase 1 - Record Management and Buffering

  • [X] Phase 2 - Indexing

  • [ ] Phase 3 - Relational Operators

  • [ ] Phase 4 - Query Optimization

See description of phases at [[https://grape.ics.uci.edu/wiki/asterix/wiki/cs222-2010-winter-SimpleDBProjectInfo][CS222 Project Page]].

  • Compiling

** Prerequisites

=sbcl= including =flexi-streams=, =fucc=, and =cl-ppcre=. =autoconf=.

To install the prerequisites, first

+BEGIN_SRC sh

sudo apt-get install sbcl sudo apt-get install autoconf

+END_SRC

Start up =sbcl= as =root=.

+BEGIN_SRC sh

sudo sbcl

+END_SRC

and enter the following code to get =flexi-streams=, =fucc=, and =cl-ppcre=:

+BEGIN_SRC lisp

(require 'asdf-install)

;; you will most likely want to do a system install ;; ignore any GPG signature warnings (asdf-install:install 'flexi-streams) ;; in-memory binary streams (asdf-install:install 'cl-ppcre) ;; pearl regular expressions (asdf-install:install 'fucc) ;; macro for parsing

+END_SRC

Additionally, I highly recommended SLIME for Emacs, although it is not necessary for compiling the code.

+BEGIN_SRC sh

sudo apt-get install slime

+END_SRC

** Compile

+BEGIN_SRC sh

autoconf && ./configure && make

+END_SRC

This will create the binary =simpledb=.

  • Usage

Use the provided =data/first.txt= and =data/last.txt= files to create an example database file, then start the SQL parser.

+BEGIN_SRC sh

./simpledb convert data/first.txt int,string ./simpledb convert data/last.txt string,int

+END_SRC sh

Now you can start the SQL parser using the following =data/schema.txt=:

+BEGIN_EXAMPLE

first ( id int, name string );

last ( name string, id int );

+END_EXAMPLE

+BEGIN_SRC sh

./simpledb parser data/schema.txt

+END_SRC

From here, you can perform SQL queries on the database, such as the following.

+BEGIN_EXAMPLE

SELECT first.name, last.name FROM first,last WHERE first.id = last.id; "Michael","Zeller"

+END_EXAMPLE

  • Implemented SQL

The following grammar is currently implemented:

+BEGIN_EXAMPLE

SELECT fields FROM tables [WHERE where-clause]

DELETE FROM table WHERE where-clause

+END_EXAMPLE

Previous:course-scheduler