visualizing a database structure with schemaspy
TRANSCRIPT
Visualizing a Database Structure with SchemaSpyAlbert Guo
Agenda
• Introduction
• SchemaSpy Parameters
• SchemaSpy Support Database Type
• Database Document Generation Process – command line
• Database Document Generation Process – ant build script
• My output
Introduction
• SchemaSpy can be a valuable asset in maintaining and publishing these models.
• Like Javadoc for Java source code, SchemaSpy provides an accurate, up-to-date view of the database structure, generated automatically from the actual database.
• As an automated tool, SchemaSpy incurs very little cost to set up and virtually no cost to maintain—the diagrams are automatically updated as the database schema evolves.
• This alone is a valuable time-saver for both development and maintenance teams.
• http://schemaspy.sourceforge.net/
SchemaSpy Parameters
Parameter Description
-t databaseType Type of database (e.g. ora, db2, etc.). Use -dbhelp for a list of built-in types. Defaults to ora.
* -db dbName Name of database to connect to
* -u user Valid database user id with read access
-s schema Database schema (optional if the same as user or isn't supported by your database)
-p password Password associated with that user. Defaults to no password.
* -o outputDirectory Directory to write the generated HTML/graphs to
* denotes required parameter.Please go to here, http://schemaspy.sourceforge.net/, to get full parameter list. * denotes required parameter.Please go to here, http://schemaspy.sourceforge.net/, to get full parameter list.
SchemaSpy Support Database Type
Type Description
db2 IBM DB2 with the 'App' Driver
db2net IBM DB2 with the 'Net' Driver
firebird Firebird
hsqldb HSQLDB Server
mssql Microsoft SQL Server
mysql MySQL
ora Oracle with OCI8 Driver
orathin Oracle with Thin Driver
pgsql PostgreSQL
sybase Sybase Server with JDBC3 Driver
sybase2 Sybase Server with JDBC2 Driver
udbt4 DB2 UDB Type 4 Driver
Database Document Generation Process – command line
Database documentDatabase document
Command lineCommand line
Retrieve database info.Retrieve database info.
generate generate
Database Document Generation Process – command line
• A MySQL example:
– java -jar schemaSpy.jar -t mysql -o library -host localhost -db library -u user -p password –notablecomments
– will create a series of files in the library directory that give the details of the schema in the database library.
• An MS SQL Server example:
– java -jar schemaSpy.jar -t mssql -db library -host localhost -port 1433 -u user -p password -o library
– does the same thing as the MySQL example, but specifies an mssql database type with MS SQL Server-specific database connection parameters.
Database Document Generation Process – ant build script
Database documentDatabase document
Retrieve database info.Retrieve database info.
generate generate
Database Document Generation Process – ant build script
Assign parameter valuesAssign parameter values
Database Document Generation Process – ant build script
Integrate command line into ant build scriptIntegrate command line into ant build script
Database Document Generation Process – ant build script
Just type in ant to generate database schema documentJust type in ant to generate database schema document
My output
My output – cont.
My output – cont.