ERD with Dia

I recently found a very cool trick using Dia to make an ERD.

  1. sudo yum install dia
  2. Get this:  http://code.google.com/p/lindenb/source/browse/trunk/src/xsl/sql2dia.xsl
  3. Then run a script like this:
  4. mysql -uyouruser -pyourpass -A -Dyourdatabase -e ‘SELECT CONCAT(“desc “,table_name,”;”) AS cmd FROM (select table_name FROM information_schema.TABLES WHERE table_schema=”yourschema”)x’ | grep -v ‘cmd’ > /home/someuser/tablelist.txt;cat /home/someuser/tablelist.txt | tr -d ‘\n’ > /home/someuser/tablelist2.txt;

    (echo “”;
    mysql -uyouruser -pyourpass -A -Dyourdatabse -X < /home/someuser/tablelist2.txt |\
    grep -v “ echo “”) > /home/someuser/tmp.xml
    xsltproc sql2dia.xsl /home/someuser/tmp.xml |\
    gzip -c > /home/someuser/file.dia;

THIS ERD WAS COMPLETED, COLOR CODED, AND ALL IN UNDER 3 HOURS

Posted in Linux, MySQL, SQL

Leave a Reply