The following example shows a View Class corresponding to the traditional employees table, with the employee's department given by a join with the departments table. See def-view-class for a description of the slot options.
(def-view-class employee (standard-db-object)
((employee-number :db-kind :key
(employee-name :db-kind :base
:type (string 20)
(employee-department :db-kind :base
(employee-job :db-kind :base
:type (string 9))
(employee-manager :db-kind :base
(employee-location :db-kind :join
:db-info (:join-class department
The def-view-class macro allows elements or lists of elements to follow
. The elements can be symbols,
, strings, integers or floats.
This syntax means that an object from the join class is only included in the join slot if the values from
to the values in
, in order. These values are calculated as follows:
Note that some database vendors may have short maximum identifier lengths. The CLOS interface uses constructed alias names for tables in its SQL queries, and long table names or long class names may cause the constructed aliases to exceed the maximum identifier length for a particular vendor.