r9727: 1 Jul 2004 Kevin Rosenberg <kevin@rosenberg.net>
[clsql.git] / doc / ref-ooddl.xml
1 <?xml version='1.0' ?>
2 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
4 <!ENTITY % myents SYSTEM "entities.inc">
5 %myents;
6 ]>
7
8 <!-- Object Oriented Data Definition Language --> 
9 <reference id="ref-ooddl"> 
10   <title>Object Oriented Data Definition Language (OODDL)</title> 
11     <partintro>
12     <para>
13       <!-- introduction --> 
14     </para>
15   </partintro>
16
17   <refentry id="standard-db-object">
18     <refnamediv>
19       <refname>STANDARD-DB-OBJECT</refname>
20       <refpurpose>Superclass for all &clsql; View Classes.</refpurpose>
21       <refclass>Class</refclass>
22     </refnamediv>
23     <refsect1>
24       <title>Class Precedence List</title>
25       <para>
26         <simplelist type="inline">
27           <member><type>standard-db-object</type></member>
28           <member><type>standard-object</type></member>
29           <member><type>t</type></member>
30         </simplelist>
31       </para>
32     </refsect1>
33     <refsect1>
34       <title>Description</title> <para>This class is the superclass
35       of all &clsql; View Classes.</para>
36     </refsect1>
37     <refsect1>
38       <title class="contenttitle">Class details</title>
39       <programlisting>(defclass STANDARD-DB-OBJECT ()(...))</programlisting>
40     </refsect1>
41     <refsect1>
42       <title class="contenttitle">Slots</title>
43       <para>
44         <simplelist> 
45           <property>slot VIEW-DATABASE is of type T</property>
46         </simplelist> 
47       </para>
48     </refsect1>
49   </refentry>
50
51   <refentry id="default-varchar-length">
52     <refnamediv>
53       <refname>*DEFAULT-STRING-LENGTH*</refname>
54       <refpurpose>Default length of SQL strings</refpurpose>
55       <refclass>Variable</refclass>
56     </refnamediv>
57     <refsect1>
58       <title>Value Type</title>
59       <para>
60         Fixnum
61       </para> 
62     </refsect1>
63     <refsect1>
64       <title>Initial Value</title>
65       <para><symbol>255</symbol></para>
66     </refsect1>
67     <refsect1>
68       <title>Description</title> 
69       <para>
70         If a slot of a class defined by
71         <function>DEF-VIEW-CLASS</function> is of the type
72         <symbol>STRING</symbol> or <symbol>VARCHAR</symbol> and does
73         not have a length specified, then the value of this variable
74         is used as SQL length.
75       </para>
76     </refsect1>
77     <refsect1>
78       <title>Examples</title>
79       <screen>
80         (let ((*default-string-length* 80))
81           (def-view-class s80 ()
82             ((a :type string)
83              (b :type (string 80))
84              (c :type varchar))))
85           (create-view-from-class 's80)   
86       </screen>
87       <para>
88         The above code causes a SQL table to be created with the SQL command
89       </para>
90       <screen>CREATE TABLE (A VARCHAR(80), B CHAR(80), C VARCHAR(80))</screen>
91     </refsect1>
92     <refsect1>
93       <title>Affected By</title>
94       <para>Some SQL backends do not support <symbol>VARCHAR</symbol>
95       lengths greater than 255 .</para>
96     </refsect1>
97     <refsect1>
98       <title>See Also</title>
99       <para>None.</para>
100     </refsect1>
101     <refsect1>
102       <title>Notes</title>
103       <para>This is a CLSQL extension to the CommonSQL API.</para>
104     </refsect1>
105   </refentry>
106
107   <refentry id="create-view-from-class">
108     <refnamediv>
109       <refname>CREATE-VIEW-FROM-CLASS</refname>
110       <refpurpose>Create a SQL table from Lisp class</refpurpose>
111       <refclass>Function</refclass>
112     </refnamediv>
113     <refsect1>
114       <title>Syntax</title>
115       <synopsis>
116       <function> (CREATE-VIEW-FROM-CLASS VIEW-CLASS-NAME &amp;KEY (DATABASE *DEFAULT-DATABASE*) (TRANSACTIONS T)) [function]</function> => <returnvalue><!-- result --></returnvalue></synopsis>
117     </refsect1>
118     <refsect1>
119       <title>Arguments and Values</title>
120       <variablelist>
121         <!-- arguments and values --> 
122       </variablelist>
123     </refsect1>
124     <refsect1>
125       <title>Description</title>
126       <para>Creates a table as defined by the View Class
127       VIEW-CLASS-NAME in DATABASE which defaults to
128       *DEFAULT-DATABASE*.
129       </para>
130     </refsect1>
131     <refsect1>
132       <title>Examples</title>
133       <screen>
134         <!-- examples -->
135       </screen>
136     </refsect1>
137     <refsect1>
138       <title>Side Effects</title>
139       <para>
140         Causes a table to be created in the SQL database.
141       </para>
142     </refsect1>
143     <refsect1>
144       <title>Affected by</title>
145       <para>
146         <simplelist>
147           <!-- affected by --> 
148         </simplelist>
149       </para>
150     </refsect1>
151     <refsect1>
152       <title>Exceptional Situations</title>
153       <para>
154         <!-- execeptional situations -->
155       </para>
156     </refsect1>
157     <refsect1>
158       <title>See Also</title>
159       <para>
160         <simplelist>
161           <!-- see also --> 
162         </simplelist>
163       </para>
164     </refsect1>
165     <refsect1>
166       <title>Notes</title>
167       <para>
168         <!-- notes --> 
169       </para>
170     </refsect1>
171   </refentry>
172
173   <refentry id="def-view-class">
174     <refnamediv>
175       <refname>DEF-VIEW-CLASS</refname>
176       <refpurpose><!-- purpose --></refpurpose>
177       <refclass>Function</refclass>
178     </refnamediv>
179     <refsect1>
180       <title>Syntax</title>
181       <synopsis>
182       <function> (DEF-VIEW-CLASS CLASS SUPERS SLOTS &amp;REST CL-OPTIONS) [macro]</function> => <returnvalue><!-- result --></returnvalue></synopsis>
183     </refsect1>
184     <refsect1>
185       <title>Arguments and Values</title>
186       <variablelist>
187         <!-- arguments and values --> 
188       </variablelist>
189     </refsect1>
190     <refsect1>
191       <title>Description</title>
192       <para>Creates a View Class called CLASS whose slots SLOTS can
193       map onto the attributes of a table in a database. If SUPERS is
194       nil then the superclass of CLASS will be STANDARD-DB-OBJECT,
195       otherwise SUPERS is a list of superclasses for CLASS which
196       must include STANDARD-DB-OBJECT or a descendent of this
197       class. The syntax of DEFCLASS is extended through the addition
198       of a class option :base-table which defines the database table
199       onto which the View Class maps and which defaults to
200       CLASS. The DEFCLASS syntax is also extended through additional
201       slot options. The :db-kind slot option specifies the kind of
202       DB mapping which is performed for this slot and defaults to
203       :base which indicates that the slot maps to an ordinary column
204       of the database table. A :db-kind value of :key indicates that
205       this slot is a special kind of :base slot which maps onto a
206       column which is one of the unique keys for the database table,
207       the value :join indicates this slot represents a join onto
208       another View Class which contains View Class objects, and the
209       value :virtual indicates a standard CLOS slot which does not
210       map onto columns of the database table. If a slot is specified
211       with :db-kind :join, the slot option :db-info contains a list
212       which specifies the nature of the join. For slots of :db-kind
213       :base or :key, the :type slot option has a special
214       interpretation such that Lisp types, such as string, integer
215       and float are automatically converted into appropriate SQL
216       types for the column onto which the slot maps. This behaviour
217       may be over-ridden using the :db-type slot option which is a
218       string specifying the vendor-specific database type for this
219       slot's column definition in the database. The :column slot
220       option specifies the name of the SQL column which the slot
221       maps onto, if :db-kind is not :virtual, and defaults to the
222       slot name. The :void-value slot option specifies the value to
223       store if the SQL value is NULL and defaults to NIL. The
224       :db-constraints slot option is a string representing an SQL
225       table constraint expression or a list of such strings.
226       </para>
227     </refsect1>
228     <refsect1>
229       <title>Examples</title>
230       <screen>
231         <!-- examples -->
232       </screen>
233     </refsect1>
234     <refsect1>
235       <title>Side Effects</title>
236       <para>
237         <!-- side effects --> 
238       </para>
239     </refsect1>
240     <refsect1>
241       <title>Affected by</title>
242       <para>
243         <simplelist>
244           <!-- affected by --> 
245         </simplelist>
246       </para>
247     </refsect1>
248     <refsect1>
249       <title>Exceptional Situations</title>
250       <para>
251         <!-- execeptional situations -->
252       </para>
253     </refsect1>
254     <refsect1>
255       <title>See Also</title>
256       <para>
257         <simplelist>
258           <!-- see also --> 
259         </simplelist>
260       </para>
261     </refsect1>
262     <refsect1>
263       <title>Notes</title>
264       <para>
265         <!-- notes --> 
266       </para>
267     </refsect1>
268   </refentry>
269
270   <refentry id="drop-view-from-class">
271     <refnamediv>
272       <refname>DROP-VIEW-FROM-CLASS</refname>
273       <refpurpose><!-- purpose --></refpurpose>
274       <refclass>Function</refclass>
275     </refnamediv>
276     <refsect1>
277       <title>Syntax</title>
278       <synopsis>
279       <function> (DROP-VIEW-FROM-CLASS VIEW-CLASS-NAME &amp;KEY (DATABASE *DEFAULT-DATABASE*)) [function]</function> => <returnvalue><!-- result --></returnvalue></synopsis>
280     </refsect1>
281     <refsect1>
282       <title>Arguments and Values</title>
283       <variablelist>
284         <!-- arguments and values --> 
285       </variablelist>
286     </refsect1>
287     <refsect1>
288       <title>Description</title>
289       <para>Removes a table defined by the View Class
290       VIEW-CLASS-NAME from DATABASE which defaults to
291       *DEFAULT-DATABASE*.
292       </para>
293     </refsect1>
294     <refsect1>
295       <title>Examples</title>
296       <screen>
297         <!-- examples -->
298       </screen>
299     </refsect1>
300     <refsect1>
301       <title>Side Effects</title>
302       <para>
303         <!-- side effects --> 
304       </para>
305     </refsect1>
306     <refsect1>
307       <title>Affected by</title>
308       <para>
309         <simplelist>
310           <!-- affected by --> 
311         </simplelist>
312       </para>
313     </refsect1>
314     <refsect1>
315       <title>Exceptional Situations</title>
316       <para>
317         <!-- execeptional situations -->
318       </para>
319     </refsect1>
320     <refsect1>
321       <title>See Also</title>
322       <para>
323         <simplelist>
324           <!-- see also --> 
325         </simplelist>
326       </para>
327     </refsect1>
328     <refsect1>
329       <title>Notes</title>
330       <para>
331         <!-- notes --> 
332       </para>
333     </refsect1>
334   </refentry>
335
336   <refentry id="list-classes">
337     <refnamediv>
338       <refname>LIST-CLASSES</refname>
339       <refpurpose><!-- purpose --></refpurpose>
340       <refclass>Function</refclass>
341     </refnamediv>
342     <refsect1>
343       <title>Syntax</title>
344       <synopsis>
345       <function> (LIST-CLASSES &amp;KEY (TEST #'IDENTITY) (ROOT-CLASS (FIND-CLASS 'STANDARD-DB-OBJECT)) (DATABASE *DEFAULT-DATABASE*)) [function]</function> => <returnvalue><!-- result --></returnvalue></synopsis>
346     </refsect1>
347     <refsect1>
348       <title>Arguments and Values</title>
349       <variablelist>
350         <!-- arguments and values --> 
351       </variablelist>
352     </refsect1>
353     <refsect1>
354       <title>Description</title>
355       <para>Returns a list of all the View Classes which
356       are connected to DATABASE, which defaults to
357       *DEFAULT-DATABASE*, and which descend from the class
358       ROOT-CLASS and which satisfy the function TEST. By
359       default ROOT-CLASS is STANDARD-DB-OBJECT and TEST is
360       IDENTITY.
361       </para>
362     </refsect1>
363     <refsect1>
364       <title>Examples</title>
365       <screen>
366         <!-- examples -->
367       </screen>
368     </refsect1>
369     <refsect1>
370       <title>Side Effects</title>
371       <para>
372         <!-- side effects --> 
373       </para>
374     </refsect1>
375     <refsect1>
376       <title>Affected by</title>
377       <para>
378         <simplelist>
379           <!-- affected by --> 
380         </simplelist>
381       </para>
382     </refsect1>
383     <refsect1>
384       <title>Exceptional Situations</title>
385       <para>
386         <!-- execeptional situations -->
387       </para>
388     </refsect1>
389     <refsect1>
390       <title>See Also</title>
391       <para>
392         <simplelist>
393           <!-- see also --> 
394         </simplelist>
395       </para>
396     </refsect1>
397     <refsect1>
398       <title>Notes</title>
399       <para>
400         <!-- notes --> 
401       </para>
402     </refsect1>
403   </refentry>
404
405
406
407
408 </reference>