Commit e886a442 authored by Ryszard Szopa's avatar Ryszard Szopa


<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="" xml:lang="en" lang="en">
<title><!--#include virtual="project-name" --></title>
<link rel="stylesheet" type="text/css" href="style.css"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<div class="header">
<p>Submarine is a Common Lisp library that's somewhere between a
PostgreSQL library an an object persistency system. It uses
Postmodern to communicate with the database. The basic idea is that
you create your classes in the metaclass DB-CLASS and submarine cares
about creating SQL tables or, if the tables already exist, checking if
they conform to the provided specification. Moreover, Submarine
supports an intuitive way of expressing both one-to-many and
many-to-many relations.</p>
<h1>Table of contents</h1>
<li><a href="#getting_submarine">Getting Submarine</a></li>
<li><a href="#dependencies">Dependencies</a></li>
<li><a href="#license">License</a></li>
<li><a href="#introduction_for_postmodern_users">Introduction for
Postmodern users</a></li>
<li><a href="#api_reference">API reference</a></li>
<a name="getting_submarine"><h1>Getting submarine</h1></a>
<p>At the moment there's only a darcs repository available:</p>
darcs get
You will also need my MOP utilities, which may be incorporated into
submarine in the close future:
darcs get
<a name="dependencies"><h1>Dependencies</h1></a>
<p>Submarine depends on Postmodern and Iterate. It uses also my
library of MOP utilities, MOP-UTILS, which may become a separate
library in the future. On platforms other than SBCL, mop-utils needs
<a name="license"><h1>License</h1></a>
<p>Submarine is released under a BSD-like license. Which approximately
means you can use the code in whatever way you like, except for
passing it off as your own or releasing a modified version without
indication that it is not the original.</p>
<a name="introduction_for_postmodern_users"><h1>Introduction for Postmodern users</h1></a>
Submarine started as a patch that added, among others, foreign keys
support to Postmodern. This meant hacking the DEFTABLE macro and
TABLE and TABLEFIELD classes. After some time I realized that my
modified Postmodern macros had become far too large and heavy to be
easy maintainable. So, I decided to leave Postmodern's code as it was
and write a separate library.
<p>Submarine tries to keep as much as possible of Postmodern's original
API. I use the same terminology, and functions with similar names will
probably do very similar things. My purpose was twofold. First of all,
I wanted to make porting programs using Postmodern to Submarine
easy. Secondly, this would allow me to use some of Marijn Haverbeke's
superb documentation nearly without any changes.</p>
<p>Main differences between Postmodern and Submarine:</p>
<li> You don't have to create DAO (database access object) classes and SQL
tables separately. You just create classes belonging to a certain
metaclass, and the library cares of the rest.</li>
<li> If the table with an appropriate name exists in the database,
Submarine will test if it has columns with the right names and
types. If a column does not exist or has a wrong type, Submarine will
offer the user a possibility to fix it. Submarine will warn, but do
nothing about any additional columns in the table.</li>
<li> Each DB-CLASS class has its own connection specification. This means
that you can just access your objects, without wrapping them in a
WITH-CONNECTION macro, and they will care about setting the right
<li> DAO is a basis class for DB-CLASS classes, and methods that are
supposed to work on an object of any DB-CLASS class use DAO as a
dispatch type. Of course, you don't have to use DAO as a base class,
but it makes a lot of things easier.</li>
<li> Submarine supports foreign keys. If you define a DB-CLASS class
with a slot whose type is another DB-CLASS, it is treated as foreign
key and an appropriate constraint is added to the database.</li>
<li> Submarine provides a function to retrieve all the elements of a
given type standing in a many-to-one relation with some DAO object.</li>
<li> The DEF-MANY-TO-MANY macro defines a many-to-many relation between
two classes and creates methods appropriate to their retrieval (it
creates a link table in the database).</li>
<li> DB-CLASS slots have an additional attribute TRANSIENT. If you set
it to a non-NIL value, it will behave just as a
STANDARD-SLOT-DEFINITION and will be ignored in database related
<li> Submarine uses MOP rather than macros to achieve its purposes. This
makes it easier to maintain and to extend.</li>
<h1><a name="api_reference">API reference</a></h1>
<p>Here you can find some TINAA generated documentation. I document my
code a lot, so it should be quite useful (<code>M-.</code> should be
your good friend).</p>
<li><a href="darcs/submarine/doc/submarine-package/">Submarine</a></li>
<li><a href="darcs/mop-utils/doc/mop-utils-package/">MOP-utils</a></li>
<p>There exists also a <a href="darcs/submarine/doc/example.lisp">poor
man's tutorial</a>.</p>
.header {
font-size: medium;
border-width: 5px;
padding: 1mm 1mm 1mm 5mm;
.footer {
font-size: small;
font-style: italic;
text-align: right;
border-width: 2px;
padding: 1mm 1mm 1mm 1mm;
.footer a:link {
.footer a:visited {
.footer a:hover {
text-decoration:underline; }
.check {font-size: x-small;
.check a:link { font-weight:bold;
text-decoration:underline; }
.check a:visited { font-weight:bold;
text-decoration:underline; }
.check a:hover { font-weight:bold;
text-decoration:underline; }
body {
width: 40em;
margin-left: 5em;
text-align: justify;
font-family: Verdana, sans;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment