SQLT-DIAGRAM(1p)
π SQLT-DIAGRAM(1p) π
okay so bestie, welcome to SQLT-DIAGRAM(1p) β it's a User Contributed Perl Documentation page and it's genuinely so useful. it's a little script that draws you a picture of your database schema. we're obsessed. let's go. β¨
β¨ NAME β¨
sqlt-diagram β automatically create a diagram from a database schema. literally it just. makes the diagram. for you. no cap. π
πΈ SYNOPSIS πΈ
./sqlt-diagram -d|-f|--from|--db=db_parser [options] schema.sql
and here are the options, all of them, in order, exactly as they live:
-o,--outputβ output file name (defaultSTDOUT)-i,--imageβ output image type ("png"or"jpeg,", default"png") β yes the comma inside the quotes is really there, that's just how it is, iykyk π-t,--titleβ title to give the schema-c,--colsβ number of columns-n,--no-linesβ don't draw lines--font-sizeβ font size ("small,""medium,""large,"or"huge,", default"medium")--gutterβ gutter size between tables--colorβ add colors π--show-fk-onlyβ only show fields that act as primary or foreign keys--natural-joinβ perform natural joins--natural-join-pkβ perform natural joins from primary keys only-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
π¦ DESCRIPTION π¦
so this script will create a picture of your schema. that's the whole vibe. the only thing it requires is the database driver argument (for SQL::Translator) β everything else is optional, she's low maintenance. and if you don't hand her an output file name? the image gets printed to STDOUT, so bestie you should redirect that output into a file. don't just let a whole image spill onto your terminal, that's not the moment. π
the default action is to assume foreign key relationships are already defined via REFERENCES or FOREIGN KEY constraints on the tables. classic, iconic, straightforward.
but. if you're parsing the schema of a file that doesn't have those constraints, that's when the natural join options come in clutch. with natural joins, fields with like names get considered foreign keys. it's giving "sure, whatever's named the same is related."
β οΈ heads up though β that can prove too permissive. like, you probably don't want a field callednameto be considered a foreign key. so you could include it in theskipoption, and then all fields callednamewill be excluded from natural joins. byename. π
a more efficient method though? simply deduce the foreign keys from primary keys to other fields named the same in other tables. use the natural-join-pk option to achieve this. chef's kiss. π
π AUTHOR π
Ken Youens-Clark <kclark@cpan.org>.
and that's the page, bestie π«Ά this was perl v5.40.0, dated 2024-11-23 β go forth and diagram, you're gonna slay. βπΈ
π¦ 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