SQLT-GRAPH(1p)
π 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
nameto count as a foreign key, right? so you can drop it in theskipoption and every field namednamegets 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-pkoption 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
- debian trixie: libsql-translator-perl 1.66-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libsql-translator-perl 1.66-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libsql-translator-perl 1.66-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms