SQLT-GRAPH(1p)

πŸ“¦
version 1.66 Β· 4 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

πŸ’– SQLT-GRAPH πŸ’–

okay bestie, so this is the manual page for sqlt-graph, which lives in section 1p of the perl docs. she's a little script that ✨automatically✨ makes a graph out of your database schema, and honestly? she ate.


🌸 NAME 🌸

sqlt-graph β€” Automatically create a graph from a database schema πŸ¦‹


πŸŽ€ SYNOPSIS πŸŽ€

like here's the whole vibe, fr fr:

./sqlt-graph -d|--db|-f|--from=db_parser [options] schema.sql

Options:

  -l|--layout        Layout schema for GraphViz
                     ("dot," "neato," "twopi"; default "dot")
  -n|--node-shape    Shape of the nodes ("record," "plaintext,"
                     "ellipse," "circle," "egg," "triangle," "box,"
                     "diamond," "trapezium," "parallelogram," "house,"
                     "hexagon," "octagon," default "record")
  -o|--output        Output file name (default STDOUT)
  -t|--output-type   Output file type ("canon", "text," "ps," "hpgl,"
                     "pcl," "mif," "pic," "gd," "gd2," "gif," "jpeg,"
                     "png", "wbmp," "cmap," "ismap", "imap", "vrml,"
                     "vtx", "mp", "fig", "svg", "plain", default "png")
  -c|--color         Add colors
  --cluster          Cluster tables
  --no-fields        Don't show field names
  --height           Image height (in inches, default "11",
                     set to "0" to undefine)
  --width            Image width (in inches, default "8.5",
                     set to "0" to undefine)
  --fontsize         custom font size for node and edge labels
  --fontname         name of custom font (or full path to font file) for
                     node, edge, and graph labels
  --nodeattr         attribute name and value (in key=val syntax) for
                     nodes; this option may be repeated to specify
                     multiple node attributes
  --edgeattr         same as --nodeattr, but for edge attributes
  --graphattr        same as --nodeattr, but for graph attributes
  --natural-join     Perform natural joins
  --natural-join-pk  Perform natural joins from primary keys only
  --show-datatypes   Show datatype of each field
  --show-sizes       Show column sizes for VARCHAR and CHAR fields
  --show-constraints Show list of constraints for each field
  -s|--skip          Fields to skip in natural joins
  --skip-tables      Comma-separated list of table names to exclude
  --skip-tables-like Comma-separated list of regexen to exclude tables
  --debug            Print debugging information
  --trace            Print parser trace info

🫢 DESCRIPTION 🫢

so. this script makes a graph of your schema. iconic behavior. πŸ’…

the only thing you actually have to give her is the database driver argument (that's the one for SQL::Translator). everything else is optional, she's low maintenance. and if you don't hand her an output file name? she just prints the image straight to STDOUT, so you better redirect that output into a file, bestie, or you're gonna get a whole image dumped at your terminal and she will not apologize. 😭

the default situation ✨

by default she assumes your foreign key relationships are already defined via REFERNCES or FOREIGN KEY constraints on the tables. (yes that spelling is what the page says, no I will not be fixing it, that's not my job, i just work here πŸŽ€)

natural joins, aka the plot twist πŸ¦‹

if you're parsing a schema of a file that doesn't have those constraints, the natural join options are gonna be your best friend. here's the tea:

  • with natural joins, fields with like names get treated as foreign keys.
  • but that's too permissive ngl, because you probably don't want a field literally called name to count as a foreign key, right? so you can drop it in the skip option and every field named name gets excluded from natural joins. bye felicia. πŸ‘‹
  • a more efficient method though? just deduce the foreign keys from primary keys to other fields that share the same name in other tables. use the natural-join-pk option for that one. periodt.

directed vs undirected, the vibe check 🌈

  • if the schema defines foreign keys β†’ the graph comes out directed, showing the direction of the relationship. arrows. slay.
  • if the foreign keys are intuited via natural joins β†’ the graph is undirected. no arrows, just vibes.

clustering, the grouping era πŸ‘‘

clustering tables lets you group and box tables according to function, or domain, or literally whatever criteria you choose. main character energy. the syntax for clustering tables is:

cluster1=table1,table2;cluster2=table3,table4

🌟 AUTHOR 🌟

Ken Youens-Clark <kclark@cpan.org>.


πŸ’œ SEE ALSO πŸ’œ

perl, SQL::Translator.


and that's the whole page, bestie πŸ₯° this was perl v5.40.0, dated 2024-11-23, and she's filed under SQLT-GRAPH(1p). go make some graphs, you got this πŸ’–βœ¨πŸŒΈ

πŸ“¦ where this page comes from