Skip to main content

Database Schemas

This example demonstrates using tbls utility to generate documentation for relational database schema.

Examples (defined in doc.clj script):

  • Chinook - documentation for the Chinook sample database using SQLite.
  • Sakila - uses the Pagila sample database and PostgreSQL.
    It may not be desirable to connect to real database just to extract schema. This example shows how to generate docs from a static DDL SQL script by loading it into a temporary Postgres instance.

Examples of wikilinks:

  • [[Album]] or [[chinook:Album]]
  • [[actor]] or [[sakila:public.actor]] or [[sakila:actor]] (without the public. schema)

Diagram format considerations

tbls supports rendering diagrams as SVG (default, uses graphviz) and Mermaid.

  • I find that Mermaid diagrams look a bit better, but a disadvantage is that for larger schemas the diagrams are scaled down and the text can end up illegible.
  • Therefore I slightly prefer the SVG format because as a workaround one can open it in another browser tab to pan and zoom to see all details.