NAME
schema_diagram - Create a diagram of a database's tables
SYNOPSIS
schema_diagram [--user username] [--password password] [--format format] [--output filename] [--tile] [--scale factor] [--paper paper_size] DBI_data_source
DESCRIPTION
Produces a diagram of the specified database, showing all the tables, listing their fields, and indicating foreign key links between tables.
The output can be various formats, including PostScript, png, SVG, and GraphViz's dot. If the poster(1) command is available then PostScript output can be tiled on to multiple sheets.
Examples
Generate a PostScript diagram of the Postgres database wedding
, saving it to the file wedding.ps:
schema_diagram DBI:Pg:dbname=wedding
Same, but tile it over multiple sheets:
schema_diagram --tile DBI:Pg:dbname=wedding
Generate a png image of the MySQL database intranet
, connecting as the user wiki
, and saving it to the file intranet.png
:
schema_diagram --format png --user wiki DBI:mysql:intranet
Same, but save to the file DB_schema.png
:
schema_diagram --output DB_schema.png --user wiki DBI:mysql:intranet
Specifying the Database
Specify the database with DBI_data_source, a string in the format used by the Perl DBI module, such as in the above examples.
If non-default authentication is required, specify them with these options:
- --user username
-
The username to the database as.
- --password password
-
The password to use when connecting to the database.
Specifying the Output
These options can be used to specify the output format and filename. By default PostScript output is generated and the filename based on the database's name.
- --format format
-
The output format. Valid values include
png
,svg
,fig
,plain
, and any format which the GraphViz module can create with anadd_*
method. The formatdot
can be used to specify GraphViz's dot format, suitable for passing todot(1)
. - --output filename
-
The name of the file to save the diagram in. If the filename has an extension which matches the desired format then there is no need to also pass the
--format
option; schema_diagram will work out the format from the filename.
Tiling
These options use the poster(1)
command to split the diagram over multiple sheets, with cutmarks suitable for printing and assembling into a large poster. There is no tiling by default.
- --tile
-
Tile the diagram. This will use the system's default paper size, and a scale factor of 0.4.
- --scale factor
-
Scale the diagram by the specified factor.
Specifying
--scale
implies--tile
. - --paper paper_size
-
Tile on to sheets of the specified paper size.
Specifying
--paper
implies--tile
.
Tweaking the Included Tables
If you wish to tweak a diagram, perhaps to remove some irrelevant tables or specify a de facto foreign key link which isn't encoded in the database, use --format dot
. Then edit the created file with a text editor (the format is quite intutive to make basic changes), and use the dot
command to generate the diagram.
SEE ALSO
DBI, GraphViz, GraphViz::DBI::FromSchema, poster
CREDITS
Written by Smylers, for Webfusion http://www.webfusion.com/
Contact me on <Smylers@cpan.org> or http://twitter.com/Smylers2
COPYRIGHT & LICENCE
Copyright 2011 Webfusion Ltd
This library is software libre; you may redistribute it and modify it under the terms of any of these licences:
The GNU General Public License, version 2
The GNU General Public License, version 3
The Artistic License 2.0