SQLT-DIAGRAM(1p)

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

πŸ’– 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 (default STDOUT)
  • -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 called name to be considered a foreign key. so you could include it in the skip option, and then all fields called name will be excluded from natural joins. bye name. πŸ’…

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