Schemaball is an SQL database schema viewer. It requires Perl and a few modules, such as GD and optionally Math::Bezier and SQL::Translator. Schemaball creates flexible visualizations of database schemas. Schemas may be read from an SQL schema dump, flat file or live database.

schemaball

home about screenshots requirements

documentation

tour tutorials README CHANGES man page

download

Perl code

Tutorials

These tutorials illustrate different features of Schemaball. Tutorials are divided into sections. Each section covers a particular aspect of a feature or set of features. Each section has its own documentation, configuration file and schema ball image.

tutorial 5.0.description

all tutorials | description | Sections 1 2 3 4 5 6 7 8 9

NAME

sbtut_05 - tracing constraints using highlight inheritance

SYNOPSIS

  <highlight>
  highlight_by_table = yes | no
  highlight_by_table_forward = yes | no
  highlight_by_table_reverse = yes | no
  highlight_by_iterations = [ 1 | 2 | 3 ... ]
  fade_factor_table = 0 .. 1
  fade_factor_link = 0 .. 1
  </highlight>

PURPOSE

This tutorial will illustrate how to use highlighting to apply a different colour scheme to elements in the schema diagram.

TUTORIAL

Starting from a Highlighted Table

Suppose we're interested in how the analysis table is connected to other tables. Start by highlight the analysis table.

  <table>
  ...
  <highlight_rx>
  ^seq_region$
  </highlight_rx>
  ...
  fill_hi    = acff96
  outline_hi = ffffff
  ...
  </table>

The resulting image is sbtut_05_01.png. This is pretty boring. To have Schemball automatically highlight tables refered to by the seq_region table,

  <link>
  stroke_hi = 3
  color_hi  = acff96
  </link>

  <highlight>
  highlight_by_table = yes
  highlight_by_table_forward = yes
  highlight_by_iterations = 1
  </highlight>

Links are highlighted by tables when 'highlight_by_table' is toggled. Links which start at the highlighted table will be highlighted, since 'highlight_by_table_forward' is toggled. Links terminating at this table will not be highlighted. The 'highlight_by_iterations' parameter determines how deep the highlight inheritance extends. Because links do not highlight tables in this example, raising the number of iterations will not make a difference.

The produced image is sbtut_05_02.png.

To automatically highlight links which terminate at the seq_region table,

  <highlight>
  ...
  highlight_by_table_forward = no
  highlight_by_table_reverse = yes
  ...
  </highlight>

The produced image is sbtut_05_03.png.

So far, this type of highlighting is no different than manually highlighting links using a regular expression, such as ^seq_region__ or __seq_region$. The virtue of automatic highlighting is made clear when both highlight_by_table and highlight_by_link are toggled.

Starting from a Highlighted Link

If you start with a highlighted link, or links, you can automatically highlight the participating tables.

  <link>
  ...
  <highlight_rx>
  __seq_region$
  </highlight_rx>
  ...
  stroke_hi = 3
  color_hi = acff96
  ...
  </link>

  <highlight>
  highlight_by_link = yes
  highlight_by_iterations = 1
  </highlight>

Even with a single iteration, inheritance of highlight from links achieves more than highlighting tables manually. There is no way to highlight a table based on what tables it connects to (because the highlight regular expression applies only to the table name), except with highlight inheritance. The produced image is sbtut_05_04.png.

Tracing Constraints

Highlights can be inherited across multiple levels of tables and constraints. To illustrate this, we'll start with a single highlighted table, translation_stable_id.

  <table>
  ...
  <highlight_rx>
  translation_stable_id
  </highlight_rx>
  ...
  </table>

To trace highlights through multiple levels, you need to allow links to inherit table highlights (highlight_by_table) and tables to inherit link highlights (highlight_by_link). In this example, we'll apply highlights to links in the forward direction, meaning that links which start at highlighted tables will be highlighted.

  <highlight>
  highlight_by_link  = yes
  highlight_by_table = yes
  highlight_by_table_forward = yes
  highlight_by_iterations = 1
  </highlight>

A single iteration of inheritance is produced in sbtut_05_05.png. Links starting at translation_stable_id are highlighted. In this case, this is the single link to the translation table. The table at which this link terminates is also highlighted, since both types of inheritance (by table and by link) are performed once.

When the number of iterations is increased to 2, links touching tables highlighted in the first iteration become highlighted.

  <highlight>
  ...
  highlight_by_iterations = 2
  ...
  </highlight>

The produced image is sbtut_05_06.png. The Looking ahead, let's set the number of iterations to some large number to see how deeply into the database the constraints that start at translation_stable_id extend.

  <highlight>
  ...
  highlight_by_iterations = 99
  ...
  </highlight>

The produced image is sbtut_05_07.png. In this image, it's hard to tell how many constraints were followed to any of the highlighted tables. The colour of the highlighted elements may be adjusted for each iteration of highlighting. This is described below.

Tracing Constraints with Variable Highlights

The highlight colours can be diluted in HSB space, to come closer to the regular colour, using

  <highlight>
  ...
  fade_factor_table =
  fade_factor_link  =
  ...
  </highlight>

The lower the fade factor, the faster the highlighted colours fade into regular colours. This type of fading is handy to distinguish inheritance depth. For example,

  <highlight>
  ...
  fade_factor_table = 0.6
  fade_factor_link  = 0.6
  ...
  </highlight>

produces sbtut_05_08.png.

Tracing Constraints with Fading Highlights

If the regular colour of the link and table is chosen to be the background colour, traced highlights and their tables will appear to fade into the background. This is a neat effect, and it is shown in sbtut_05_09.png.

HISTORY

BUGS

Please report errors and suggestions to martink@bcgsc.ca

AUTHOR

Martin Krzywinski, mkweb.bcgsc.ca, martink@bcgsc.ca

$Id: schemaball,v 1.5 2003/10/27 20:25:11 martink Exp $

CONTACT

  Martin Krzywinski
  Genome Sciences Centre
  Vancouver BC Canada
  www.bcgsc.ca
  mkweb.bcgsc.ca
  martink@bcgsc.ca