User's Manual

Appendix D. PDL Syntax 195
model tutorial;
object type Publication {
BigDecimal id = publications.publication_id INTEGER;
String name = publications.name VARCHAR(400);
object key (id);
}
object type Magazine extends Publication {
// we need to specify the size of the String attribute so we know
// whether it is actually a String or if it is really a Clob
String issueNumber = magazines.issue_number VARCHAR(30);
// notice that because it extends Publication, there is not an
// explicitly "object key" declaration. Rather, there is
// a "reference key" declaration and "id" is not defined
// as one of the attributes
reference key (magazines.magazine_id);
}
object type Article {
BigDecimal id = articles.title INTEGER;
String title = articles.title VARCHAR(30);
object key (articles.article_id);
}
// this is an "association block" associating "articles" and "magazines"
association {
// note that the Attribute Type is an Object Type (Article)
// and not a standard Java Type. Also notice the order of the
// join path and see the note below.
Article[0..n] articles = join magazines.magazine_id
to magazine_article_map.magazine_id,
join magazine_article_map.article_id
to articles.article_id;
Magazine[0..n] magazines = join articles.article_id
to magazine_article_map.article_id,
join magazine_article_map.magazine_id
to magazines.magazine_id;
// the next line is the Link Attribute
BigDecimal pageNumber = magazine_article_map.page_number INTEGER;
}
object type Paragraph {
BigDecimal id = paragraphs.paragraph_id INTEGER;
String text = paragraphs.text CLOB;
object key (paragraphs.paragraph_id);
}
association {
Article[1..1] articles = join paragraphs.article_id
to articles.article_id;
// notice the composite keyword indicates that if the article does
// not exist then the paragraph also does not exist
composite Paragraph[0..n] paragraphs = join articles.article_id
to paragraphs.article_id;
}