64 Chapter 9. Persistence Tutorial
• A database schema to handle the storage of the Data Objects.
Some designers may feel more comfortable starting with a database design and then designing the
objects that use the schema,or vice versa. You may begin with either one, but both should bedesigned
as part of the persistence layer. The UML model is typically designed for the Data Objects using a
UML modeling tool.
This tutorial will use a hypothetical database schema composed of publications, magazines, articles,
paragraphs, and authors. This goalof this tutorial is to help youbetter understand how this technology
can be used with WAF. In practice, the entire data model below will be automatically generated by the
persistence layer using the metadata defined in the PDL file. Therefore, none of the data model below
will have to be created by the developer.
The tutorial will begin by using two simple objects: a Publication and a Magazine. The schema will
be expanded throughout the tutorial. To see the full schema that is used throughout the tutorial, please
see Appendix D PDL Syntax.
create table publications (
publication_id integer
constraint publications_pub_id_nn
not null
constraint publications_pub_id_pk
primary key,
type varchar(400)
constraint publications_pub_type_nn
not null,
name varchar(400)
constraint publications_pub_name_nn
not null,
constraint publications_pub_name_un unique(type, name)
);
create table magazines (
magazine_id integer
constraint magazines_magazine_id_fk
references publications
constraint magazines_magazine_id_pk
primary key,
issue_number varchar(30)
);
9.2.3. Defining an Object Type in PDL
9.2.3.1. The PDL File
APDL fileisa textfile thathas a.pdlextension and canbe parsedusing thePDLgrammar (Appendix
D PDL Syntax). It is made up of a model declaration followed by block declarations. These block
declarations can be object typedefinitions, association blocks, DaraQuery blocks, andData Operation
blocks.
The only required item is the Model declaration, as this declaration informs the compiler of which
namespace to use. It is common to have one for all DataQuery and DataOperationdefinitions and
one file for each Object Type. However, it is possible to combine all Object Type definitions into a
single file. It is also possible to include DataQuery and DataOperations in their own files or in-
line with Object Type Definitions. Data Associations are normally found with one of the Object Type
definitions used within the association.
You can find a list of PDL reserved words, as well as the PDL grammar, in Appendix D PDL Syntax.