Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Section


Column

Purpose

Excerpt

Visualize the structure of a database.

Available since
Warning

This macro was added in version 5.

4

3.3 of the PlantUML Plugin und removed in version 2023.3 (with the Confluence 8 support)



Parameter

Parameter datasource is required, all others are optional.

NameDescription
datasource

Name of datasources to visualize

(warning) Datasources must be configured by a Confluence administrator before they can be used.
A short guide can be found here.

schemaNameName of schema to visualize.
The table name is prefixed with the schema name if none is selected.
tableTypes

Comma separated list of types to show in graphics. The available types depend on the database. They can be determined with the database-info macro. Common ones are:

  • TABLE (default)
  • VIEW
  • INDEX
  • SEQUENCE

The type will be shown as stereotype above the table name if more than one is selected.

tableNameFilter

Show only tables with these names in generated graphic.

Wildcards _ and % can be used as in a SQL SELECT. An additional filtering is possible with tableNameRegEx.

Note

  • This selection is done inside the database. It will be faster than tableNameRegEx in most cases.
  • It depends on the database whether this is case sensitive or case insensitive
columnNameFilter

Show only columns with these names in generated graphic.

It works like tableNameFilter.

tableNameRegEx

Show only tables with these names in generated graphic.

Table names are defined as regular expression, e.g. show all tables whose names start with A,B,C or D or end with NEW:

Code Block
([A-D].*|.*NEW)

Note

  • tableNameFilter is executed before tableNameRegEx
  • Regular expressions are case sensitive but you can place (?i) in front to make them insensitive
  • | does not work in Confluence 3 as this character separates paramters. It requires Confluence 4.
columnNameRegEx

Show only columns with these names in generated graphic.

It works like tableNameRegEx.

showColumnsIf true column names and their data types are shown.
showComments

If true and column comments comment exists they it will be shown after --.

Note: Comments are an elegant way to document a database schema but they are not part of the SQL standard. Some databases support them (e.g. PostgreSQL, Oracle), others do not (MySQL).

(available since 5.4.1)

showDefaultValues

If true and a default values exist they it will be shown after =.

(available since 5.4.1)

showIndexes

If true the indexes of each table are shown below the column names.

Indexes can also be shown as separate boxes by adding INDEX to the list of tableTypes but this will need more space on the graphic.

useForeignKeys

If true foreign keys will be used to determine relations between tables. They are drawn as lines.

(available since 5.4.1)

relationRegEx

Relations between tables can also be drawn without foreign key constraints. This requires a consistent naming schema and a regular expression to describe how tables are related.

The regular expression is checked against: <tablename1>.<columname1> <tablename2>.<columname2>

A relation between table <tablename1> and <tablename2> is drawn when the regular expression matches.

Example:
The primary key of an table is named id.
A column which refers to this is named <tablename>_id.
A relation between tables person and team has to be drawn if there is for example: person.id and team.person_id.
The regular expression hast to match:

Code Block
person.id team.person_id
team.id match.team_id
...

The following regular expression would do this:

Code Block
^(.*)\.id .*\.\1_id$

 Note: Only tables and columns which are shown in the output will be used the determine relations!

(available since 5.4.1)

nodeFontsizeFont size. Default is 9.
additional

The appearance of the graphics can be changed by adding some DOT commands here. This will overwrite the default set by the macro.

Example: set minimal width of all table boxes to 3.5 inches, change background, font colour and font:

Code Block
node [ width="3.5", fontcolor="#FFFFFF", fillcolor="#222222", fontname="Serif"]; 

For more details see http://www.graphviz.org/doc/info/attrs.html.

format

PNG (default)

SVG (beta)

exportNameThe graph will be stored as attachment if exportName is given.
debug

true = Enable debugging.



Column

 



Column

Sample Images

 



Sample Code

Code Block
{database-structure:datasource=jira|showIndexes=true|showColumns=false}
{database-structure:datasource=confluence|schemaName=public|tableTypes=TABLE|tableNameFilter=os_%|nodeFontsize=11|
                    additional=node [ width="3.5", fontcolor="#FFFFFF", fillcolor="#222222", fontname="Serif"];}

...

  • Class/Package Name: de.griffel.confluence.plugins.plantuml
  • Loglevel INFO will output
    • DOT file from which the graphic is generated
    • measurements how long it took to retrieve tables, columns, foreign keys and who long it took to create DOT and graphic
  • Loglevel DEBUG will additionally output
    • each table, column, foreign key and idex which was retrieved from the database

 

 

 

...