Monday, 10 September 2012

Easy visualisation of database schemas

This is easy using SQLFairy, under Ubuntu, as simple as:
sudo apt-get install sqlfairy
Next, dump your database tables, e.g. for MySQL:
mysqldump -u username -p -d mydatabase > mydatabase.sql
Finally, for a PNG image of your schema:
sqlt-graph -f MySQL -o mydatabase.png -t png mydatabase.sql
If your schema lacks explicit foreign keys, try the –natural-join options (man sqlt-graph, man sqlt-diagram)

Here's an example for a SQLite DB:

Get the schema dump:
echo ".schema" | sqlite3 ~/.liferea_1.4/liferea.db >> liferea.sql
Generate a SVG diagram with:
sqlt-graph -c --natural-join --from=SQLite -t svg -o liferea_schema.svg liferea.sql

Possibly Related Posts

No comments:

Post a Comment