Thread: writing a simple sql parser and database program

writing a simple sql parser and database program

From
"Peter Michaux"
Date:
Hi,

I would like to learn how to write a simple SQL parser and database
program. This is for an embeded situation where I can't use a database
program like postgre. Jumping into the postgre source code seems a
little overwelming as I don't have a general understanding of how this
is done. Is there a link or book that explains the basics of how a
database parses SQL and how it then operates on the data?

Thank you,
Peter


Re: writing a simple sql parser and database program

From
"Jonah H. Harris"
Date:
On 11/7/06, Peter Michaux <petermichaux@gmail.com> wrote:
> I would like to learn how to write a simple SQL parser and database
> program ... Is there a link or book that explains the basics of how a
> database parses SQL and how it then operates on the data?

For a fairly good learning resource, you can check out LEAP
(http://leap.sourceforge.net/); it doesn't use SQL and instead, has
it's own relational language... but it's a good place to start if you
want to learn how this stuff works.  You can also check out pql
(http://www.ibiblio.org/pub/Linux/apps/database/sql/pql-0.8.1.src+bin.tgz),
which uses a SQL-ish language, or SQLite for a little more advanced
example (http://www.sqlite.org)

Of course, there's a lot of fairly simple and easy-to-understand Java
databases like hsql or McKoi too.  Most Java databases are going to be
using ANLTR or JavaCC for their parsers while C/C++-based databases
use Bison, ANTLR/PCCTS, or a hand-written SQL parser.

A Java database is going to be a lot easier to understand the concepts
of than one in C.

-- 
Jonah H. Harris, Software Architect | phone: 732.331.1300
EnterpriseDB Corporation            | fax: 732.331.1301
33 Wood Ave S, 2nd Floor            | jharris@enterprisedb.com
Iselin, New Jersey 08830            | http://www.enterprisedb.com/