19.10.2015 Views

workbench-en.a4

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Customizing DBDoc Model Reporting Templates<br />

That is, the model contains two schemata, Airlines and Airports.<br />

Data Dictionaries<br />

It is important to understand the relationship betwe<strong>en</strong> sections and data dictionaries in more detail. In a data dictionary the key for a<br />

variable is the variable name, a marker. The variable value is the variable's data. The <strong>en</strong>try for a section in a data dictionary is differ<strong>en</strong>t.<br />

For a section <strong>en</strong>try in a data dictionary, the key is the section name, the marker. However, the value associated with the key<br />

is a list of data dictionaries. In MySQL Workb<strong>en</strong>ch each section is usually associated with a data dictionary. You can think of a<br />

section as activating its associated dictionary (or dictionaries).<br />

Wh<strong>en</strong> a template is processed, data dictionaries are loaded in a hierarchical pattern, forming a tree of data dictionaries. This is illustrated<br />

by the following table:<br />

Data Dictionary<br />

MAIN<br />

SCHEMATA<br />

TABLES<br />

COLUMNS_LISTING<br />

REL_LISTING<br />

INDICES_LISTING<br />

Loads Data Dictionary<br />

SCHEMATA<br />

TABLES, COLUMNS (Detailed is true), FOREIGN_KEYS (Detailed is true),<br />

INDICES (Detailed is true)<br />

REL_LISTING, INDICES_LISTING, COLUMNS_LISTING, TA-<br />

BLE_COMMENT_LISTING, DDL_LISTING<br />

COLUMNS (Detailed is false)<br />

REL (Detailed is false)<br />

INDICES (Detailed is false)<br />

The root of the tree is the main dictionary. Additional dictionaries are th<strong>en</strong> loaded from the root to form the dictionary tree.<br />

Note<br />

If a template has no sections in it, th<strong>en</strong> any variables used in the template will be looked up in the main dictionary. If a<br />

variable is not found in the main dictionary (which can be thought of as associated with the default, or main, section)<br />

th<strong>en</strong> no data will be g<strong>en</strong>erated in the output file for that marker.<br />

Evaluation of variables<br />

The tree structure of the data dictionaries is important wh<strong>en</strong> it comes to evaluation of variables. As variables are defined in data<br />

dictionaries, their associated value only has meaning wh<strong>en</strong> that particular data dictionary is active, and that means wh<strong>en</strong> the section<br />

associated with that data dictionary is active. Wh<strong>en</strong> a variable lookup occurs, the system will check the data dictionary associated<br />

with the curr<strong>en</strong>t section. If the variable value can be found there the replacem<strong>en</strong>t is made. However, if the variable's value is not<br />

found in the curr<strong>en</strong>t data dictionary th<strong>en</strong> the par<strong>en</strong>t data dictionary will be checked for the variable's value and so on up the tree until<br />

the main data dictionary, or root, is reached.<br />

This can best be illustrated by an example. Assume we want to display the names of all columns in a model. Consider the following<br />

template as an attempt to achieve this:<br />

Report<br />

------<br />

Column Name: {{COLUMN_NAME}}<br />

This template will produce no output, ev<strong>en</strong> for a model that contains many columns. In this example the only data dictionary active<br />

is the main dictionary. COLUMN_NAME however is stored in the COLUMNS data dictionary, which is associated with the COLUMNS<br />

section.<br />

With this knowledge the template can be improved as follows:<br />

Report<br />

------<br />

{{#COLUMNS}}<br />

Column Name: {{COLUMN_NAME}}<br />

{{/COLUMNS}}<br />

This still does not produce output. Referring to the table Data Dictionary Hierarchy Tree explains why. The COLUMNS data dictionary<br />

has the par<strong>en</strong>t dictionary COLUMNS_LISTING. COLUMNS_LISTING has the par<strong>en</strong>t TABLES, which has the par<strong>en</strong>t<br />

SCHEMATA, whose par<strong>en</strong>t is the main dictionary. Remember in order for a dictionary to be involved in variable lookup, its associated<br />

section must curr<strong>en</strong>tly be active.<br />

76

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!