/cl-simpledb

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

Primary LanguageCommon LispGNU General Public License v2.0GPL-2.0

SimpleDB Instructions

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 CS222 Project Page.

Compiling

Prerequisites

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

To install the prerequisites, first

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

Start up sbcl as root.

sudo sbcl

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

(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

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

sudo apt-get install slime

Compile

autoconf && ./configure && make

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.

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

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

first
(
id int,
name string
);

last
(
name string,
id int
);
./simpledb parser data/schema.txt

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

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

Implemented SQL

The following grammar is currently implemented:

SELECT fields
FROM tables
[WHERE where-clause]

DELETE FROM table
WHERE where-clause