Skip to content

Instantly share code, notes, and snippets.

@ckhung
Last active March 14, 2024 09:40
Show Gist options
  • Save ckhung/c208ad5b72e7ebe216fd0bfc7fb1cb7a to your computer and use it in GitHub Desktop.
Save ckhung/c208ad5b72e7ebe216fd0bfc7fb1cb7a to your computer and use it in GitHub Desktop.
[Generating ER Diagrams directly from *.sql files without even installing mysql](https://ckhung.medium.com/drawing-er-diagram-from-sql-file-alone-e7bef8cfe34b) / [在命令列上從 *.sql 檔直接產生 ER Diagram](https://newtoypia.blogspot.com/2022/04/sql-er-diagram.html)
#!/usr/bin/python3
# convert the output (as json) of
# https://github.com/iamcal/SQLParser
# to the input of
# https://github.com/BurntSushi/erd
# or to the input of
# https://github.com/ehne/ERDot
#
# For example, suppose you have ~/sakila-schema.sql from https://downloads.mysql.com/docs/sakila-db.tar.gz
# php pmysql.php ~/sakila-schema.sql | python3 ~/json2erd.py -t busu | erd -f svg -e spline > ~/sakila.busu.svg
# or
# php pmysql.php ~/sakila-schema.sql | python3 ~/json2erd.py -t ehne > ~/sakila.erd.json
# erdot ~/sakila.erd.json
# dot -Tsvg ~/sakila.dot > ~/sakila.ehne.svg
import argparse, fileinput, json
from warnings import warn
parser = argparse.ArgumentParser(
description='SQLParser-generated .json to erd .er converter',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('-t', '--type', type=str, default='busu',
help='output type: busu or ehne')
parser.add_argument('jsonfile', nargs='*',
help='input .json file generated by iamcal/SQLParser, or stdin if omitted')
args = parser.parse_args()
all_tables = json.loads(''.join(fileinput.input(args.jsonfile)))
all_relationships = []
for tn in all_tables:
# convert the 'fields' array to the 'fields' dict,
# and add a 'prefix' field to each item
new_fields = {}
for f in all_tables[tn]['fields']:
new_fields[f['name']] = f
f['prefix'] = ''
all_tables[tn]['fields'] = new_fields
for index in all_tables[tn]['indexes']:
if index['type'] == 'PRIMARY':
for field in index['cols']:
all_tables[tn]['fields'][field['name']]['primary'] = True
elif index['type'] == 'FOREIGN':
for field in index['cols']:
all_tables[tn]['fields'][field['name']]['foreign'] = True
for field in all_tables[tn]['fields'].values():
if 'primary' in field: field['prefix'] = '*'
if 'foreign' in field: field['prefix'] += '+'
# print(json.dumps(all_tables, indent=4))
for tn in all_tables:
for index in filter(lambda x : x['type'] == 'FOREIGN', all_tables[tn]['indexes']):
rel = {
't1':tn, 'f1':index['cols'][0]['name'], 'm1':'*',
't2':index['ref_table'], 'f2':index['ref_cols'][0]['name']
}
rel['m2'] = '?' if any(all_tables[index['ref_table']]['fields'][f['name']]['null'] for f in index['ref_cols']) else '1'
all_relationships.append(rel)
# print(json.dumps(all_relationships, indent=4))
if args.type == 'busu':
print('entity {bgcolor: "#ececfc", size: "20"}\n')
for (tn, tab) in all_tables.items():
print('[', tn, ']')
for field in tab['fields'].values():
print(field['prefix'] + field['name'])
print()
for rel in all_relationships:
print('{} {}--{} {}'.format(rel['t1'], rel['m1'], rel['m2'], rel['t2']))
elif args.type == 'ehne':
out = {
'tables': {
tn: {
field['prefix']+field['name']: field['type'] \
for field in all_tables[tn]['fields'].values()
} for tn in all_tables
},
'relations':[
'{}:{} {}--{} {}:{}'.format(rel['t1'], rel['f1'], rel['m1'], rel['m2'], rel['t2'], rel['f2']) \
for rel in all_relationships
],
'rankAdjustments':'',
'label':''
}
print(json.dumps(out, indent=4))
else:
warn('unknown output type "' + args.type + '"')
<?php
ini_set('display_errors', 1);
error_reporting(E_ERROR | E_WARNING | E_PARSE);
# in shell: composer require iamcal/sql-parser
# see "Installation" section of https://github.com/iamcal/SQLParser
require_once 'vendor/autoload.php';
use iamcal\SQLParser;
$N = $argc - 1;
if ($N != 1) {
error_log("need exactly one argument (a .sql mysql ddl file) but $N was found");
exit(1);
}
$sql = file_get_contents($argv[1]);
$obj = new SQLParser();
#$tokens = $obj->lex($sql);
#print_r($tokens);
#exit;
$obj->parse($sql);
#echo json_encode($obj->tables['bounces']['fields'], JSON_PRETTY_PRINT)."\n";
echo json_encode($obj->tables, JSON_PRETTY_PRINT)."\n";
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 2.43.0 (0)
-->
<!-- Title: G Pages: 1 -->
<svg width="1853pt" height="1447pt"
viewBox="0.00 0.00 1852.80 1447.30" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(14.4 1432.9)">
<title>G</title>
<polygon fill="white" stroke="transparent" points="-14.4,14.4 -14.4,-1432.9 1838.4,-1432.9 1838.4,14.4 -14.4,14.4"/>
<!-- actor -->
<g id="node1" class="node">
<title>actor</title>
<polygon fill="none" stroke="black" points="743,-1397 743,-1418 921,-1418 921,-1397 743,-1397"/>
<text text-anchor="start" x="814" y="-1404.8" font-family="Helvetica,sans-Serif" font-style="italic" font-size="14.00">actor</text>
<polygon fill="none" stroke="black" points="743,-1370 743,-1397 921,-1397 921,-1370 743,-1370"/>
<text text-anchor="start" x="749" y="-1380.8" font-family="Helvetica,sans-Serif" font-size="14.00">PK actor_id </text>
<text text-anchor="start" x="831" y="-1380.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">SMALLINT</text>
<polygon fill="none" stroke="black" points="743,-1343 743,-1370 921,-1370 921,-1343 743,-1343"/>
<text text-anchor="start" x="749" y="-1353.8" font-family="Helvetica,sans-Serif" font-size="14.00">first_name </text>
<text text-anchor="start" x="828" y="-1353.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">VARCHAR</text>
<polygon fill="none" stroke="black" points="743,-1316 743,-1343 921,-1343 921,-1316 743,-1316"/>
<text text-anchor="start" x="749" y="-1326.8" font-family="Helvetica,sans-Serif" font-size="14.00">last_name </text>
<text text-anchor="start" x="825" y="-1326.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">VARCHAR</text>
<polygon fill="none" stroke="black" points="743,-1289 743,-1316 921,-1316 921,-1289 743,-1289"/>
<text text-anchor="start" x="749" y="-1299.8" font-family="Helvetica,sans-Serif" font-size="14.00">last_update </text>
<text text-anchor="start" x="834" y="-1299.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">TIMESTAMP</text>
</g>
<!-- address -->
<g id="node2" class="node">
<title>address</title>
<polygon fill="none" stroke="black" points="1205.5,-245 1205.5,-266 1388.5,-266 1388.5,-245 1205.5,-245"/>
<text text-anchor="start" x="1269" y="-252.8" font-family="Helvetica,sans-Serif" font-style="italic" font-size="14.00">address</text>
<polygon fill="none" stroke="black" points="1205.5,-218 1205.5,-245 1388.5,-245 1388.5,-218 1205.5,-218"/>
<text text-anchor="start" x="1211.5" y="-228.8" font-family="Helvetica,sans-Serif" font-size="14.00">PK address_id </text>
<text text-anchor="start" x="1312.5" y="-228.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">SMALLINT</text>
<polygon fill="none" stroke="black" points="1205.5,-191 1205.5,-218 1388.5,-218 1388.5,-191 1205.5,-191"/>
<text text-anchor="start" x="1211.5" y="-201.8" font-family="Helvetica,sans-Serif" font-size="14.00">address </text>
<text text-anchor="start" x="1271.5" y="-201.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">VARCHAR</text>
<polygon fill="none" stroke="black" points="1205.5,-164 1205.5,-191 1388.5,-191 1388.5,-164 1205.5,-164"/>
<text text-anchor="start" x="1211.5" y="-174.8" font-family="Helvetica,sans-Serif" font-size="14.00">address2 </text>
<text text-anchor="start" x="1280.5" y="-174.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">VARCHAR</text>
<polygon fill="none" stroke="black" points="1205.5,-137 1205.5,-164 1388.5,-164 1388.5,-137 1205.5,-137"/>
<text text-anchor="start" x="1211.5" y="-147.8" font-family="Helvetica,sans-Serif" font-size="14.00">district </text>
<text text-anchor="start" x="1264.5" y="-147.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">VARCHAR</text>
<polygon fill="none" stroke="black" points="1205.5,-110 1205.5,-137 1388.5,-137 1388.5,-110 1205.5,-110"/>
<text text-anchor="start" x="1211.5" y="-120.8" font-family="Helvetica,sans-Serif" font-size="14.00">FK city_id </text>
<text text-anchor="start" x="1282.5" y="-120.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">SMALLINT</text>
<polygon fill="none" stroke="black" points="1205.5,-83 1205.5,-110 1388.5,-110 1388.5,-83 1205.5,-83"/>
<text text-anchor="start" x="1211.5" y="-93.8" font-family="Helvetica,sans-Serif" font-size="14.00">postal_code </text>
<text text-anchor="start" x="1298.5" y="-93.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">VARCHAR</text>
<polygon fill="none" stroke="black" points="1205.5,-56 1205.5,-83 1388.5,-83 1388.5,-56 1205.5,-56"/>
<text text-anchor="start" x="1211.5" y="-66.8" font-family="Helvetica,sans-Serif" font-size="14.00">phone </text>
<text text-anchor="start" x="1260.5" y="-66.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">VARCHAR</text>
<polygon fill="none" stroke="black" points="1205.5,-29 1205.5,-56 1388.5,-56 1388.5,-29 1205.5,-29"/>
<text text-anchor="start" x="1211.5" y="-39.8" font-family="Helvetica,sans-Serif" font-size="14.00">last_update </text>
<text text-anchor="start" x="1296.5" y="-39.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">TIMESTAMP</text>
</g>
<!-- city -->
<g id="node4" class="node">
<title>city</title>
<polygon fill="none" stroke="black" points="1424,-136 1424,-157 1606,-157 1606,-136 1424,-136"/>
<text text-anchor="start" x="1502.5" y="-143.8" font-family="Helvetica,sans-Serif" font-style="italic" font-size="14.00">city</text>
<polygon fill="none" stroke="black" points="1424,-109 1424,-136 1606,-136 1606,-109 1424,-109"/>
<text text-anchor="start" x="1430" y="-119.8" font-family="Helvetica,sans-Serif" font-size="14.00">PK city_id </text>
<text text-anchor="start" x="1501" y="-119.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">SMALLINT</text>
<polygon fill="none" stroke="black" points="1424,-82 1424,-109 1606,-109 1606,-82 1424,-82"/>
<text text-anchor="start" x="1430" y="-92.8" font-family="Helvetica,sans-Serif" font-size="14.00">city </text>
<text text-anchor="start" x="1460" y="-92.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">VARCHAR</text>
<polygon fill="none" stroke="black" points="1424,-55 1424,-82 1606,-82 1606,-55 1424,-55"/>
<text text-anchor="start" x="1430" y="-65.8" font-family="Helvetica,sans-Serif" font-size="14.00">FK country_id </text>
<text text-anchor="start" x="1530" y="-65.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">SMALLINT</text>
<polygon fill="none" stroke="black" points="1424,-28 1424,-55 1606,-55 1606,-28 1424,-28"/>
<text text-anchor="start" x="1430" y="-38.8" font-family="Helvetica,sans-Serif" font-size="14.00">last_update </text>
<text text-anchor="start" x="1515" y="-38.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">TIMESTAMP</text>
</g>
<!-- address&#45;&gt;city -->
<g id="edge1" class="edge">
<title>address:city_id&#45;&gt;city:city_id</title>
<path fill="none" stroke="black" d="M1397.03,-123C1403.71,-123 1408.26,-123 1414.94,-123"/>
<polygon fill="black" stroke="black" points="1397,-123 1388,-118.95 1392.5,-123 1388,-123 1388,-123 1388,-123 1392.5,-123 1388,-127.05 1397,-123 1397,-123"/>
<polyline fill="none" stroke="black" points="1424,-123 1419.5,-123 "/>
<polygon fill="black" stroke="black" points="1418.6,-118.5 1418.6,-127.5 1416.8,-127.5 1416.8,-118.5 1418.6,-118.5"/>
<polyline fill="none" stroke="black" points="1419.5,-123 1415,-123 "/>
</g>
<!-- category -->
<g id="node3" class="node">
<title>category</title>
<polygon fill="none" stroke="black" points="743,-824 743,-845 921,-845 921,-824 743,-824"/>
<text text-anchor="start" x="801.5" y="-831.8" font-family="Helvetica,sans-Serif" font-style="italic" font-size="14.00">category</text>
<polygon fill="none" stroke="black" points="743,-797 743,-824 921,-824 921,-797 743,-797"/>
<text text-anchor="start" x="749" y="-807.8" font-family="Helvetica,sans-Serif" font-size="14.00">PK category_id </text>
<text text-anchor="start" x="856" y="-807.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">TINYINT</text>
<polygon fill="none" stroke="black" points="743,-770 743,-797 921,-797 921,-770 743,-770"/>
<text text-anchor="start" x="749" y="-780.8" font-family="Helvetica,sans-Serif" font-size="14.00">name </text>
<text text-anchor="start" x="793" y="-780.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">VARCHAR</text>
<polygon fill="none" stroke="black" points="743,-743 743,-770 921,-770 921,-743 743,-743"/>
<text text-anchor="start" x="749" y="-753.8" font-family="Helvetica,sans-Serif" font-size="14.00">last_update </text>
<text text-anchor="start" x="834" y="-753.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">TIMESTAMP</text>
</g>
<!-- country -->
<g id="node5" class="node">
<title>country</title>
<polygon fill="none" stroke="black" points="1642,-81 1642,-102 1824,-102 1824,-81 1642,-81"/>
<text text-anchor="start" x="1706" y="-88.8" font-family="Helvetica,sans-Serif" font-style="italic" font-size="14.00">country</text>
<polygon fill="none" stroke="black" points="1642,-54 1642,-81 1824,-81 1824,-54 1642,-54"/>
<text text-anchor="start" x="1648" y="-64.8" font-family="Helvetica,sans-Serif" font-size="14.00">PK country_id </text>
<text text-anchor="start" x="1748" y="-64.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">SMALLINT</text>
<polygon fill="none" stroke="black" points="1642,-27 1642,-54 1824,-54 1824,-27 1642,-27"/>
<text text-anchor="start" x="1648" y="-37.8" font-family="Helvetica,sans-Serif" font-size="14.00">country </text>
<text text-anchor="start" x="1706" y="-37.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">VARCHAR</text>
<polygon fill="none" stroke="black" points="1642,0 1642,-27 1824,-27 1824,0 1642,0"/>
<text text-anchor="start" x="1648" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00">last_update </text>
<text text-anchor="start" x="1733" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">TIMESTAMP</text>
</g>
<!-- city&#45;&gt;country -->
<g id="edge2" class="edge">
<title>city:country_id&#45;&gt;country:country_id</title>
<path fill="none" stroke="black" d="M1615.03,-68C1621.71,-68 1626.26,-68 1632.94,-68"/>
<polygon fill="black" stroke="black" points="1615,-68 1606,-63.95 1610.5,-68 1606,-68 1606,-68 1606,-68 1610.5,-68 1606,-72.05 1615,-68 1615,-68"/>
<polyline fill="none" stroke="black" points="1642,-68 1637.5,-68 "/>
<polygon fill="black" stroke="black" points="1636.6,-63.5 1636.6,-72.5 1634.8,-72.5 1634.8,-63.5 1636.6,-63.5"/>
<polyline fill="none" stroke="black" points="1637.5,-68 1633,-68 "/>
</g>
<!-- customer -->
<g id="node6" class="node">
<title>customer</title>
<polygon fill="none" stroke="black" points="478,-372 478,-393 672,-393 672,-372 478,-372"/>
<text text-anchor="start" x="542" y="-379.8" font-family="Helvetica,sans-Serif" font-style="italic" font-size="14.00">customer</text>
<polygon fill="none" stroke="black" points="478,-345 478,-372 672,-372 672,-345 478,-345"/>
<text text-anchor="start" x="484" y="-355.8" font-family="Helvetica,sans-Serif" font-size="14.00">PK customer_id </text>
<text text-anchor="start" x="596" y="-355.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">SMALLINT</text>
<polygon fill="none" stroke="black" points="478,-318 478,-345 672,-345 672,-318 478,-318"/>
<text text-anchor="start" x="484" y="-328.8" font-family="Helvetica,sans-Serif" font-size="14.00">FK store_id </text>
<text text-anchor="start" x="565" y="-328.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">TINYINT</text>
<polygon fill="none" stroke="black" points="478,-291 478,-318 672,-318 672,-291 478,-291"/>
<text text-anchor="start" x="484" y="-301.8" font-family="Helvetica,sans-Serif" font-size="14.00">first_name </text>
<text text-anchor="start" x="563" y="-301.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">VARCHAR</text>
<polygon fill="none" stroke="black" points="478,-264 478,-291 672,-291 672,-264 478,-264"/>
<text text-anchor="start" x="484" y="-274.8" font-family="Helvetica,sans-Serif" font-size="14.00">last_name </text>
<text text-anchor="start" x="560" y="-274.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">VARCHAR</text>
<polygon fill="none" stroke="black" points="478,-237 478,-264 672,-264 672,-237 478,-237"/>
<text text-anchor="start" x="484" y="-247.8" font-family="Helvetica,sans-Serif" font-size="14.00">email </text>
<text text-anchor="start" x="527" y="-247.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">VARCHAR</text>
<polygon fill="none" stroke="black" points="478,-210 478,-237 672,-237 672,-210 478,-210"/>
<text text-anchor="start" x="484" y="-220.8" font-family="Helvetica,sans-Serif" font-size="14.00">FK address_id </text>
<text text-anchor="start" x="585" y="-220.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">SMALLINT</text>
<polygon fill="none" stroke="black" points="478,-183 478,-210 672,-210 672,-183 478,-183"/>
<text text-anchor="start" x="484" y="-193.8" font-family="Helvetica,sans-Serif" font-size="14.00">active </text>
<text text-anchor="start" x="530" y="-193.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">BOOLEAN</text>
<polygon fill="none" stroke="black" points="478,-156 478,-183 672,-183 672,-156 478,-156"/>
<text text-anchor="start" x="484" y="-166.8" font-family="Helvetica,sans-Serif" font-size="14.00">create_date </text>
<text text-anchor="start" x="569" y="-166.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">DATETIME</text>
<polygon fill="none" stroke="black" points="478,-129 478,-156 672,-156 672,-129 478,-129"/>
<text text-anchor="start" x="484" y="-139.8" font-family="Helvetica,sans-Serif" font-size="14.00">last_update </text>
<text text-anchor="start" x="569" y="-139.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">TIMESTAMP</text>
</g>
<!-- customer&#45;&gt;address -->
<g id="edge3" class="edge">
<title>customer:address_id&#45;&gt;address:address_id</title>
<path fill="none" stroke="black" d="M682.27,-222.99C895.08,-222.35 953,-200.07 1169,-224 1181.73,-225.41 1186.54,-229.5 1195.85,-231.22"/>
<polygon fill="black" stroke="black" points="682,-222.99 672.99,-218.95 677.5,-222.99 673,-223 673,-223 673,-223 677.5,-222.99 673.01,-227.05 682,-222.99 682,-222.99"/>
<polyline fill="none" stroke="black" points="1205,-232 1200.52,-231.62 "/>
<polygon fill="black" stroke="black" points="1200,-227.06 1199.24,-236.03 1197.44,-235.87 1198.21,-226.91 1200,-227.06"/>
<polyline fill="none" stroke="black" points="1200.52,-231.62 1196.03,-231.24 "/>
</g>
<!-- store -->
<g id="node16" class="node">
<title>store</title>
<polygon fill="none" stroke="black" points="725,-371 725,-392 939,-392 939,-371 725,-371"/>
<text text-anchor="start" x="814" y="-378.8" font-family="Helvetica,sans-Serif" font-style="italic" font-size="14.00">store</text>
<polygon fill="none" stroke="black" points="725,-344 725,-371 939,-371 939,-344 725,-344"/>
<text text-anchor="start" x="731" y="-354.8" font-family="Helvetica,sans-Serif" font-size="14.00">PK store_id </text>
<text text-anchor="start" x="812" y="-354.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">TINYINT</text>
<polygon fill="none" stroke="black" points="725,-317 725,-344 939,-344 939,-317 725,-317"/>
<text text-anchor="start" x="731" y="-327.8" font-family="Helvetica,sans-Serif" font-size="14.00">FK manager_staff_id </text>
<text text-anchor="start" x="878" y="-327.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">TINYINT</text>
<polygon fill="none" stroke="black" points="725,-290 725,-317 939,-317 939,-290 725,-290"/>
<text text-anchor="start" x="731" y="-300.8" font-family="Helvetica,sans-Serif" font-size="14.00">FK address_id </text>
<text text-anchor="start" x="832" y="-300.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">SMALLINT</text>
<polygon fill="none" stroke="black" points="725,-263 725,-290 939,-290 939,-263 725,-263"/>
<text text-anchor="start" x="731" y="-273.8" font-family="Helvetica,sans-Serif" font-size="14.00">last_update </text>
<text text-anchor="start" x="816" y="-273.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">TIMESTAMP</text>
</g>
<!-- customer&#45;&gt;store -->
<g id="edge4" class="edge">
<title>customer:store_id&#45;&gt;store:store_id</title>
<path fill="none" stroke="black" d="M681.92,-333.25C696.26,-337.64 700.65,-352.24 714.93,-356.7"/>
<polygon fill="black" stroke="black" points="681.91,-333.25 673.56,-327.99 677.46,-332.63 673,-332 673,-332 673,-332 677.46,-332.63 672.44,-336.01 681.91,-333.25 681.91,-333.25"/>
<polyline fill="none" stroke="black" points="724,-358 719.55,-357.36 "/>
<polygon fill="black" stroke="black" points="719.29,-352.78 718.02,-361.69 716.23,-361.43 717.51,-352.52 719.29,-352.78"/>
<polyline fill="none" stroke="black" points="719.55,-357.36 715.09,-356.72 "/>
</g>
<!-- film -->
<g id="node7" class="node">
<title>film</title>
<polygon fill="none" stroke="black" points="714,-1232 714,-1253 950,-1253 950,-1232 714,-1232"/>
<text text-anchor="start" x="818.5" y="-1239.8" font-family="Helvetica,sans-Serif" font-style="italic" font-size="14.00">film</text>
<polygon fill="none" stroke="black" points="714,-1205 714,-1232 950,-1232 950,-1205 714,-1205"/>
<text text-anchor="start" x="720" y="-1215.8" font-family="Helvetica,sans-Serif" font-size="14.00">PK film_id </text>
<text text-anchor="start" x="793" y="-1215.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">SMALLINT</text>
<polygon fill="none" stroke="black" points="714,-1178 714,-1205 950,-1205 950,-1178 714,-1178"/>
<text text-anchor="start" x="720" y="-1188.8" font-family="Helvetica,sans-Serif" font-size="14.00">title </text>
<text text-anchor="start" x="751" y="-1188.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">VARCHAR</text>
<polygon fill="none" stroke="black" points="714,-1151 714,-1178 950,-1178 950,-1151 714,-1151"/>
<text text-anchor="start" x="720" y="-1161.8" font-family="Helvetica,sans-Serif" font-size="14.00">description </text>
<text text-anchor="start" x="802" y="-1161.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">TEXT</text>
<polygon fill="none" stroke="black" points="714,-1124 714,-1151 950,-1151 950,-1124 714,-1124"/>
<text text-anchor="start" x="720" y="-1134.8" font-family="Helvetica,sans-Serif" font-size="14.00">release_year </text>
<text text-anchor="start" x="812" y="-1134.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">YEAR</text>
<polygon fill="none" stroke="black" points="714,-1097 714,-1124 950,-1124 950,-1097 714,-1097"/>
<text text-anchor="start" x="720" y="-1107.8" font-family="Helvetica,sans-Serif" font-size="14.00">FK language_id </text>
<text text-anchor="start" x="831" y="-1107.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">TINYINT</text>
<polygon fill="none" stroke="black" points="714,-1070 714,-1097 950,-1097 950,-1070 714,-1070"/>
<text text-anchor="start" x="720" y="-1080.8" font-family="Helvetica,sans-Serif" font-size="14.00">FK original_language_id </text>
<text text-anchor="start" x="889" y="-1080.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">TINYINT</text>
<polygon fill="none" stroke="black" points="714,-1043 714,-1070 950,-1070 950,-1043 714,-1043"/>
<text text-anchor="start" x="720" y="-1053.8" font-family="Helvetica,sans-Serif" font-size="14.00">rental_duration </text>
<text text-anchor="start" x="830" y="-1053.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">TINYINT</text>
<polygon fill="none" stroke="black" points="714,-1016 714,-1043 950,-1043 950,-1016 714,-1016"/>
<text text-anchor="start" x="720" y="-1026.8" font-family="Helvetica,sans-Serif" font-size="14.00">rental_rate </text>
<text text-anchor="start" x="799" y="-1026.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">DECIMAL</text>
<polygon fill="none" stroke="black" points="714,-989 714,-1016 950,-1016 950,-989 714,-989"/>
<text text-anchor="start" x="720" y="-999.8" font-family="Helvetica,sans-Serif" font-size="14.00">length </text>
<text text-anchor="start" x="769" y="-999.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">SMALLINT</text>
<polygon fill="none" stroke="black" points="714,-962 714,-989 950,-989 950,-962 714,-962"/>
<text text-anchor="start" x="720" y="-972.8" font-family="Helvetica,sans-Serif" font-size="14.00">replacement_cost </text>
<text text-anchor="start" x="847" y="-972.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">DECIMAL</text>
<polygon fill="none" stroke="black" points="714,-935 714,-962 950,-962 950,-935 714,-935"/>
<text text-anchor="start" x="720" y="-945.8" font-family="Helvetica,sans-Serif" font-size="14.00">rating </text>
<text text-anchor="start" x="766" y="-945.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">ENUM</text>
<polygon fill="none" stroke="black" points="714,-908 714,-935 950,-935 950,-908 714,-908"/>
<text text-anchor="start" x="720" y="-918.8" font-family="Helvetica,sans-Serif" font-size="14.00">special_features </text>
<text text-anchor="start" x="837" y="-918.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">SET</text>
<polygon fill="none" stroke="black" points="714,-881 714,-908 950,-908 950,-881 714,-881"/>
<text text-anchor="start" x="720" y="-891.8" font-family="Helvetica,sans-Serif" font-size="14.00">last_update </text>
<text text-anchor="start" x="805" y="-891.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">TIMESTAMP</text>
</g>
<!-- language -->
<g id="node12" class="node">
<title>language</title>
<polygon fill="none" stroke="black" points="988.5,-1110 988.5,-1131 1166.5,-1131 1166.5,-1110 988.5,-1110"/>
<text text-anchor="start" x="1045" y="-1117.8" font-family="Helvetica,sans-Serif" font-style="italic" font-size="14.00">language</text>
<polygon fill="none" stroke="black" points="988.5,-1083 988.5,-1110 1166.5,-1110 1166.5,-1083 988.5,-1083"/>
<text text-anchor="start" x="994.5" y="-1093.8" font-family="Helvetica,sans-Serif" font-size="14.00">PK language_id </text>
<text text-anchor="start" x="1105.5" y="-1093.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">TINYINT</text>
<polygon fill="none" stroke="black" points="988.5,-1056 988.5,-1083 1166.5,-1083 1166.5,-1056 988.5,-1056"/>
<text text-anchor="start" x="994.5" y="-1066.8" font-family="Helvetica,sans-Serif" font-size="14.00">name </text>
<text text-anchor="start" x="1038.5" y="-1066.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">CHAR</text>
<polygon fill="none" stroke="black" points="988.5,-1029 988.5,-1056 1166.5,-1056 1166.5,-1029 988.5,-1029"/>
<text text-anchor="start" x="994.5" y="-1039.8" font-family="Helvetica,sans-Serif" font-size="14.00">last_update </text>
<text text-anchor="start" x="1079.5" y="-1039.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">TIMESTAMP</text>
</g>
<!-- film&#45;&gt;language -->
<g id="edge5" class="edge">
<title>film:language_id&#45;&gt;language:language_id</title>
<path fill="none" stroke="black" d="M959.14,-1109.5C966.7,-1106.79 970.9,-1101.12 978.51,-1098.45"/>
<polygon fill="black" stroke="black" points="958.88,-1109.54 949.34,-1107 954.44,-1110.27 950,-1111 950,-1111 950,-1111 954.44,-1110.27 950.66,-1115 958.88,-1109.54 958.88,-1109.54"/>
<polyline fill="none" stroke="black" points="987.5,-1097 983.06,-1097.71 "/>
<polygon fill="black" stroke="black" points="981.45,-1093.41 982.88,-1102.3 981.11,-1102.59 979.68,-1093.7 981.45,-1093.41"/>
<polyline fill="none" stroke="black" points="983.06,-1097.71 978.61,-1098.43 "/>
</g>
<!-- film&#45;&gt;language -->
<g id="edge6" class="edge">
<title>film:original_language_id&#45;&gt;language:language_id</title>
<path fill="none" stroke="black" d="M959.1,-1085.39C966.66,-1087.91 970.95,-1093.18 978.55,-1095.66"/>
<polygon fill="black" stroke="black" points="958.9,-1085.36 950.61,-1080 954.45,-1084.68 950,-1084 950,-1084 950,-1084 954.45,-1084.68 949.39,-1088 958.9,-1085.36 958.9,-1085.36"/>
<polyline fill="none" stroke="black" points="987.5,-1097 983.05,-1096.33 "/>
<polygon fill="black" stroke="black" points="982.83,-1091.75 981.49,-1100.65 979.71,-1100.38 981.05,-1091.48 982.83,-1091.75"/>
<polyline fill="none" stroke="black" points="983.05,-1096.33 978.6,-1095.67 "/>
</g>
<!-- film_actor -->
<g id="node8" class="node">
<title>film_actor</title>
<polygon fill="none" stroke="black" points="483,-1328 483,-1349 668,-1349 668,-1328 483,-1328"/>
<text text-anchor="start" x="541" y="-1335.8" font-family="Helvetica,sans-Serif" font-style="italic" font-size="14.00">film_actor</text>
<polygon fill="none" stroke="black" points="483,-1301 483,-1328 668,-1328 668,-1301 483,-1301"/>
<text text-anchor="start" x="489" y="-1311.8" font-family="Helvetica,sans-Serif" font-size="14.00">PK FK actor_id </text>
<text text-anchor="start" x="592" y="-1311.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">SMALLINT</text>
<polygon fill="none" stroke="black" points="483,-1274 483,-1301 668,-1301 668,-1274 483,-1274"/>
<text text-anchor="start" x="489" y="-1284.8" font-family="Helvetica,sans-Serif" font-size="14.00">PK FK film_id </text>
<text text-anchor="start" x="583" y="-1284.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">SMALLINT</text>
<polygon fill="none" stroke="black" points="483,-1247 483,-1274 668,-1274 668,-1247 483,-1247"/>
<text text-anchor="start" x="489" y="-1257.8" font-family="Helvetica,sans-Serif" font-size="14.00">last_update </text>
<text text-anchor="start" x="574" y="-1257.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">TIMESTAMP</text>
</g>
<!-- film_actor&#45;&gt;actor -->
<g id="edge7" class="edge">
<title>film_actor:actor_id&#45;&gt;actor:actor_id</title>
<path fill="none" stroke="black" d="M677.98,-1316.08C708.81,-1324.14 702.16,-1374.64 732.83,-1382.87"/>
<polygon fill="black" stroke="black" points="677.94,-1316.08 669.49,-1310.98 673.47,-1315.54 669,-1315 669,-1315 669,-1315 673.47,-1315.54 668.51,-1319.02 677.94,-1316.08 677.94,-1316.08"/>
<polyline fill="none" stroke="black" points="742,-1384 737.53,-1383.45 "/>
<polygon fill="black" stroke="black" points="737.19,-1378.87 736.09,-1387.8 734.3,-1387.58 735.41,-1378.65 737.19,-1378.87"/>
<polyline fill="none" stroke="black" points="737.53,-1383.45 733.07,-1382.9 "/>
</g>
<!-- film_actor&#45;&gt;film -->
<g id="edge8" class="edge">
<title>film_actor:film_id&#45;&gt;film:film_id</title>
<path fill="none" stroke="black" d="M677.91,-1285.18C698.01,-1275.55 685,-1230.58 705.01,-1220.86"/>
<polygon fill="black" stroke="black" points="677.82,-1285.2 668.19,-1283.03 673.41,-1286.1 669,-1287 669,-1287 669,-1287 673.41,-1286.1 669.81,-1290.97 677.82,-1285.2 677.82,-1285.2"/>
<polyline fill="none" stroke="black" points="714,-1219 709.59,-1219.91 "/>
<polygon fill="black" stroke="black" points="707.8,-1215.68 709.62,-1224.5 707.86,-1224.86 706.04,-1216.05 707.8,-1215.68"/>
<polyline fill="none" stroke="black" points="709.59,-1219.91 705.19,-1220.82 "/>
</g>
<!-- film_category -->
<g id="node9" class="node">
<title>film_category</title>
<polygon fill="none" stroke="black" points="477,-1055 477,-1076 673,-1076 673,-1055 477,-1055"/>
<text text-anchor="start" x="528" y="-1062.8" font-family="Helvetica,sans-Serif" font-style="italic" font-size="14.00">film_category</text>
<polygon fill="none" stroke="black" points="477,-1028 477,-1055 673,-1055 673,-1028 477,-1028"/>
<text text-anchor="start" x="483" y="-1038.8" font-family="Helvetica,sans-Serif" font-size="14.00">PK FK film_id </text>
<text text-anchor="start" x="577" y="-1038.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">SMALLINT</text>
<polygon fill="none" stroke="black" points="477,-1001 477,-1028 673,-1028 673,-1001 477,-1001"/>
<text text-anchor="start" x="483" y="-1011.8" font-family="Helvetica,sans-Serif" font-size="14.00">PK FK category_id </text>
<text text-anchor="start" x="612" y="-1011.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">TINYINT</text>
<polygon fill="none" stroke="black" points="477,-974 477,-1001 673,-1001 673,-974 477,-974"/>
<text text-anchor="start" x="483" y="-984.8" font-family="Helvetica,sans-Serif" font-size="14.00">last_update </text>
<text text-anchor="start" x="568" y="-984.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">TIMESTAMP</text>
</g>
<!-- film_category&#45;&gt;category -->
<g id="edge10" class="edge">
<title>film_category:category_id&#45;&gt;category:category_id</title>
<path fill="none" stroke="black" d="M683.25,-1013.26C757.94,-1000.47 658.15,-824.78 732.6,-811.76"/>
<polygon fill="black" stroke="black" points="682.97,-1013.29 673.68,-1009.96 678.49,-1013.64 674,-1014 674,-1014 674,-1014 678.49,-1013.64 674.32,-1018.04 682.97,-1013.29 682.97,-1013.29"/>
<polyline fill="none" stroke="black" points="742,-811 737.51,-811.36 "/>
<polygon fill="black" stroke="black" points="736.25,-806.95 736.98,-815.92 735.19,-816.07 734.46,-807.1 736.25,-806.95"/>
<polyline fill="none" stroke="black" points="737.51,-811.36 733.03,-811.73 "/>
</g>
<!-- film_category&#45;&gt;film -->
<g id="edge9" class="edge">
<title>film_category:film_id&#45;&gt;film:film_id</title>
<path fill="none" stroke="black" d="M683.31,-1042.95C741.85,-1056.26 646.16,-1204.73 704.69,-1218.05"/>
<polygon fill="black" stroke="black" points="682.95,-1042.92 674.41,-1037.97 678.48,-1042.46 674,-1042 674,-1042 674,-1042 678.48,-1042.46 673.59,-1046.03 682.95,-1042.92 682.95,-1042.92"/>
<polyline fill="none" stroke="black" points="714,-1219 709.52,-1218.54 "/>
<polygon fill="black" stroke="black" points="709.09,-1213.97 708.17,-1222.93 706.38,-1222.74 707.3,-1213.79 709.09,-1213.97"/>
<polyline fill="none" stroke="black" points="709.52,-1218.54 705.05,-1218.08 "/>
</g>
<!-- film_text -->
<g id="node10" class="node">
<title>film_text</title>
<polygon fill="none" stroke="black" points="20,-823 20,-844 175,-844 175,-823 20,-823"/>
<text text-anchor="start" x="67" y="-830.8" font-family="Helvetica,sans-Serif" font-style="italic" font-size="14.00">film_text</text>
<polygon fill="none" stroke="black" points="20,-796 20,-823 175,-823 175,-796 20,-796"/>
<text text-anchor="start" x="26" y="-806.8" font-family="Helvetica,sans-Serif" font-size="14.00">PK film_id </text>
<text text-anchor="start" x="99" y="-806.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">SMALLINT</text>
<polygon fill="none" stroke="black" points="20,-769 20,-796 175,-796 175,-769 20,-769"/>
<text text-anchor="start" x="26" y="-779.8" font-family="Helvetica,sans-Serif" font-size="14.00">title </text>
<text text-anchor="start" x="57" y="-779.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">VARCHAR</text>
<polygon fill="none" stroke="black" points="20,-742 20,-769 175,-769 175,-742 20,-742"/>
<text text-anchor="start" x="26" y="-752.8" font-family="Helvetica,sans-Serif" font-size="14.00">description </text>
<text text-anchor="start" x="108" y="-752.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">TEXT</text>
</g>
<!-- inventory -->
<g id="node11" class="node">
<title>inventory</title>
<polygon fill="none" stroke="black" points="472,-611 472,-632 678,-632 678,-611 472,-611"/>
<text text-anchor="start" x="541.5" y="-618.8" font-family="Helvetica,sans-Serif" font-style="italic" font-size="14.00">inventory</text>
<polygon fill="none" stroke="black" points="472,-584 472,-611 678,-611 678,-584 472,-584"/>
<text text-anchor="start" x="478" y="-594.8" font-family="Helvetica,sans-Serif" font-size="14.00">PK inventory_id </text>
<text text-anchor="start" x="590" y="-594.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">MEDIUMINT</text>
<polygon fill="none" stroke="black" points="472,-557 472,-584 678,-584 678,-557 472,-557"/>
<text text-anchor="start" x="478" y="-567.8" font-family="Helvetica,sans-Serif" font-size="14.00">FK film_id </text>
<text text-anchor="start" x="551" y="-567.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">SMALLINT</text>
<polygon fill="none" stroke="black" points="472,-530 472,-557 678,-557 678,-530 472,-530"/>
<text text-anchor="start" x="478" y="-540.8" font-family="Helvetica,sans-Serif" font-size="14.00">FK store_id </text>
<text text-anchor="start" x="559" y="-540.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">TINYINT</text>
<polygon fill="none" stroke="black" points="472,-503 472,-530 678,-530 678,-503 472,-503"/>
<text text-anchor="start" x="478" y="-513.8" font-family="Helvetica,sans-Serif" font-size="14.00">last_update </text>
<text text-anchor="start" x="563" y="-513.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">TIMESTAMP</text>
</g>
<!-- inventory&#45;&gt;film -->
<g id="edge12" class="edge">
<title>inventory:film_id&#45;&gt;film:film_id</title>
<path fill="none" stroke="black" d="M686.33,-574.49C738.68,-623.2 653.32,-1166.77 705.67,-1215.51"/>
<polygon fill="black" stroke="black" points="686.3,-574.48 679.56,-567.26 682.15,-572.74 678,-571 678,-571 678,-571 682.15,-572.74 676.44,-574.74 686.3,-574.48 686.3,-574.48"/>
<polyline fill="none" stroke="black" points="714,-1219 709.85,-1217.26 "/>
<polygon fill="black" stroke="black" points="710.76,-1212.76 707.28,-1221.06 705.62,-1220.37 709.1,-1212.07 710.76,-1212.76"/>
<polyline fill="none" stroke="black" points="709.85,-1217.26 705.7,-1215.52 "/>
</g>
<!-- inventory&#45;&gt;store -->
<g id="edge11" class="edge">
<title>inventory:store_id&#45;&gt;store:store_id</title>
<path fill="none" stroke="black" d="M687,-542.18C750.68,-529.38 651.38,-371.75 714.93,-358.84"/>
<polygon fill="black" stroke="black" points="686.96,-542.18 677.63,-538.97 682.48,-542.59 678,-543 678,-543 678,-543 682.48,-542.59 678.37,-547.03 686.96,-542.18 686.96,-542.18"/>
<polyline fill="none" stroke="black" points="724,-358 719.52,-358.41 "/>
<polygon fill="black" stroke="black" points="718.21,-354.02 719.04,-362.98 717.25,-363.14 716.42,-354.18 718.21,-354.02"/>
<polyline fill="none" stroke="black" points="719.52,-358.41 715.04,-358.83 "/>
</g>
<!-- payment -->
<g id="node13" class="node">
<title>payment</title>
<polygon fill="none" stroke="black" points="0,-685 0,-706 194,-706 194,-685 0,-685"/>
<text text-anchor="start" x="66" y="-692.8" font-family="Helvetica,sans-Serif" font-style="italic" font-size="14.00">payment</text>
<polygon fill="none" stroke="black" points="0,-658 0,-685 194,-685 194,-658 0,-658"/>
<text text-anchor="start" x="6" y="-668.8" font-family="Helvetica,sans-Serif" font-size="14.00">PK payment_id </text>
<text text-anchor="start" x="114" y="-668.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">SMALLINT</text>
<polygon fill="none" stroke="black" points="0,-631 0,-658 194,-658 194,-631 0,-631"/>
<text text-anchor="start" x="6" y="-641.8" font-family="Helvetica,sans-Serif" font-size="14.00">FK customer_id </text>
<text text-anchor="start" x="118" y="-641.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">SMALLINT</text>
<polygon fill="none" stroke="black" points="0,-604 0,-631 194,-631 194,-604 0,-604"/>
<text text-anchor="start" x="6" y="-614.8" font-family="Helvetica,sans-Serif" font-size="14.00">FK staff_id </text>
<text text-anchor="start" x="84" y="-614.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">TINYINT</text>
<polygon fill="none" stroke="black" points="0,-577 0,-604 194,-604 194,-577 0,-577"/>
<text text-anchor="start" x="6" y="-587.8" font-family="Helvetica,sans-Serif" font-size="14.00">FK rental_id </text>
<text text-anchor="start" x="92" y="-587.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">INT</text>
<polygon fill="none" stroke="black" points="0,-550 0,-577 194,-577 194,-550 0,-550"/>
<text text-anchor="start" x="6" y="-560.8" font-family="Helvetica,sans-Serif" font-size="14.00">amount </text>
<text text-anchor="start" x="64" y="-560.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">DECIMAL</text>
<polygon fill="none" stroke="black" points="0,-523 0,-550 194,-550 194,-523 0,-523"/>
<text text-anchor="start" x="6" y="-533.8" font-family="Helvetica,sans-Serif" font-size="14.00">payment_date </text>
<text text-anchor="start" x="110" y="-533.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">DATETIME</text>
<polygon fill="none" stroke="black" points="0,-496 0,-523 194,-523 194,-496 0,-496"/>
<text text-anchor="start" x="6" y="-506.8" font-family="Helvetica,sans-Serif" font-size="14.00">last_update </text>
<text text-anchor="start" x="91" y="-506.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">TIMESTAMP</text>
</g>
<!-- payment&#45;&gt;customer -->
<g id="edge14" class="edge">
<title>payment:customer_id&#45;&gt;customer:customer_id</title>
<path fill="none" stroke="black" d="M202.94,-642.78C243.08,-620.27 192.96,-433.23 230,-396 306.07,-319.54 362.71,-356.74 467.7,-358.9"/>
<polygon fill="black" stroke="black" points="202.73,-642.83 193.02,-641.07 198.37,-643.92 194,-645 194,-645 194,-645 198.37,-643.92 194.98,-648.93 202.73,-642.83 202.73,-642.83"/>
<polyline fill="none" stroke="black" points="477,-359 472.5,-358.95 "/>
<polygon fill="black" stroke="black" points="471.65,-354.44 471.55,-363.44 469.75,-363.42 469.85,-354.43 471.65,-354.44"/>
<polyline fill="none" stroke="black" points="472.5,-358.95 468,-358.91 "/>
</g>
<!-- rental -->
<g id="node14" class="node">
<title>rental</title>
<polygon fill="none" stroke="black" points="230,-603 230,-624 436,-624 436,-603 230,-603"/>
<text text-anchor="start" x="312.5" y="-610.8" font-family="Helvetica,sans-Serif" font-style="italic" font-size="14.00">rental</text>
<polygon fill="none" stroke="black" points="230,-576 230,-603 436,-603 436,-576 230,-576"/>
<text text-anchor="start" x="236" y="-586.8" font-family="Helvetica,sans-Serif" font-size="14.00">PK rental_id </text>
<text text-anchor="start" x="322" y="-586.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">INT</text>
<polygon fill="none" stroke="black" points="230,-549 230,-576 436,-576 436,-549 230,-549"/>
<text text-anchor="start" x="236" y="-559.8" font-family="Helvetica,sans-Serif" font-size="14.00">rental_date </text>
<text text-anchor="start" x="318" y="-559.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">DATETIME</text>
<polygon fill="none" stroke="black" points="230,-522 230,-549 436,-549 436,-522 230,-522"/>
<text text-anchor="start" x="236" y="-532.8" font-family="Helvetica,sans-Serif" font-size="14.00">FK inventory_id </text>
<text text-anchor="start" x="348" y="-532.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">MEDIUMINT</text>
<polygon fill="none" stroke="black" points="230,-495 230,-522 436,-522 436,-495 230,-495"/>
<text text-anchor="start" x="236" y="-505.8" font-family="Helvetica,sans-Serif" font-size="14.00">FK customer_id </text>
<text text-anchor="start" x="348" y="-505.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">SMALLINT</text>
<polygon fill="none" stroke="black" points="230,-468 230,-495 436,-495 436,-468 230,-468"/>
<text text-anchor="start" x="236" y="-478.8" font-family="Helvetica,sans-Serif" font-size="14.00">return_date </text>
<text text-anchor="start" x="321" y="-478.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">DATETIME</text>
<polygon fill="none" stroke="black" points="230,-441 230,-468 436,-468 436,-441 230,-441"/>
<text text-anchor="start" x="236" y="-451.8" font-family="Helvetica,sans-Serif" font-size="14.00">FK staff_id </text>
<text text-anchor="start" x="314" y="-451.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">TINYINT</text>
<polygon fill="none" stroke="black" points="230,-414 230,-441 436,-441 436,-414 230,-414"/>
<text text-anchor="start" x="236" y="-424.8" font-family="Helvetica,sans-Serif" font-size="14.00">last_update </text>
<text text-anchor="start" x="321" y="-424.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">TIMESTAMP</text>
</g>
<!-- payment&#45;&gt;rental -->
<g id="edge13" class="edge">
<title>payment:rental_id&#45;&gt;rental:rental_id</title>
<path fill="none" stroke="black" d="M203.03,-590C209.71,-590 214.26,-590 220.94,-590"/>
<polygon fill="black" stroke="black" points="203,-590 194,-585.95 198.5,-590 194,-590 194,-590 194,-590 198.5,-590 194,-594.05 203,-590 203,-590"/>
<polyline fill="none" stroke="black" points="230,-590 225.5,-590 "/>
<polygon fill="black" stroke="black" points="224.6,-585.5 224.6,-594.5 222.8,-594.5 222.8,-585.5 224.6,-585.5"/>
<polyline fill="none" stroke="black" points="225.5,-590 221,-590 "/>
</g>
<!-- staff -->
<g id="node15" class="node">
<title>staff</title>
<polygon fill="none" stroke="black" points="986.5,-584 986.5,-605 1169.5,-605 1169.5,-584 986.5,-584"/>
<text text-anchor="start" x="1062" y="-591.8" font-family="Helvetica,sans-Serif" font-style="italic" font-size="14.00">staff</text>
<polygon fill="none" stroke="black" points="986.5,-557 986.5,-584 1169.5,-584 1169.5,-557 986.5,-557"/>
<text text-anchor="start" x="992.5" y="-567.8" font-family="Helvetica,sans-Serif" font-size="14.00">PK staff_id </text>
<text text-anchor="start" x="1070.5" y="-567.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">TINYINT</text>
<polygon fill="none" stroke="black" points="986.5,-530 986.5,-557 1169.5,-557 1169.5,-530 986.5,-530"/>
<text text-anchor="start" x="992.5" y="-540.8" font-family="Helvetica,sans-Serif" font-size="14.00">first_name </text>
<text text-anchor="start" x="1071.5" y="-540.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">VARCHAR</text>
<polygon fill="none" stroke="black" points="986.5,-503 986.5,-530 1169.5,-530 1169.5,-503 986.5,-503"/>
<text text-anchor="start" x="992.5" y="-513.8" font-family="Helvetica,sans-Serif" font-size="14.00">last_name </text>
<text text-anchor="start" x="1068.5" y="-513.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">VARCHAR</text>
<polygon fill="none" stroke="black" points="986.5,-476 986.5,-503 1169.5,-503 1169.5,-476 986.5,-476"/>
<text text-anchor="start" x="992.5" y="-486.8" font-family="Helvetica,sans-Serif" font-size="14.00">FK address_id </text>
<text text-anchor="start" x="1093.5" y="-486.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">SMALLINT</text>
<polygon fill="none" stroke="black" points="986.5,-449 986.5,-476 1169.5,-476 1169.5,-449 986.5,-449"/>
<text text-anchor="start" x="992.5" y="-459.8" font-family="Helvetica,sans-Serif" font-size="14.00">picture </text>
<text text-anchor="start" x="1045.5" y="-459.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">BLOB</text>
<polygon fill="none" stroke="black" points="986.5,-422 986.5,-449 1169.5,-449 1169.5,-422 986.5,-422"/>
<text text-anchor="start" x="992.5" y="-432.8" font-family="Helvetica,sans-Serif" font-size="14.00">email </text>
<text text-anchor="start" x="1035.5" y="-432.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">VARCHAR</text>
<polygon fill="none" stroke="black" points="986.5,-395 986.5,-422 1169.5,-422 1169.5,-395 986.5,-395"/>
<text text-anchor="start" x="992.5" y="-405.8" font-family="Helvetica,sans-Serif" font-size="14.00">FK store_id </text>
<text text-anchor="start" x="1073.5" y="-405.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">TINYINT</text>
<polygon fill="none" stroke="black" points="986.5,-368 986.5,-395 1169.5,-395 1169.5,-368 986.5,-368"/>
<text text-anchor="start" x="992.5" y="-378.8" font-family="Helvetica,sans-Serif" font-size="14.00">active </text>
<text text-anchor="start" x="1038.5" y="-378.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">BOOLEAN</text>
<polygon fill="none" stroke="black" points="986.5,-341 986.5,-368 1169.5,-368 1169.5,-341 986.5,-341"/>
<text text-anchor="start" x="992.5" y="-351.8" font-family="Helvetica,sans-Serif" font-size="14.00">username </text>
<text text-anchor="start" x="1067.5" y="-351.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">VARCHAR</text>
<polygon fill="none" stroke="black" points="986.5,-314 986.5,-341 1169.5,-341 1169.5,-314 986.5,-314"/>
<text text-anchor="start" x="992.5" y="-324.8" font-family="Helvetica,sans-Serif" font-size="14.00">password </text>
<text text-anchor="start" x="1064.5" y="-324.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">VARCHAR</text>
<polygon fill="none" stroke="black" points="986.5,-287 986.5,-314 1169.5,-314 1169.5,-287 986.5,-287"/>
<text text-anchor="start" x="992.5" y="-297.8" font-family="Helvetica,sans-Serif" font-size="14.00">last_update </text>
<text text-anchor="start" x="1077.5" y="-297.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">TIMESTAMP</text>
</g>
<!-- payment&#45;&gt;staff -->
<g id="edge15" class="edge">
<title>payment:staff_id&#45;&gt;staff:staff_id</title>
<path fill="none" stroke="black" d="M202.89,-619.71C213.35,-624.35 215.13,-637.2 230,-642 419.5,-703.24 480.45,-676.24 678,-651 815.14,-633.48 843.33,-573.77 976.64,-571.09"/>
<polygon fill="black" stroke="black" points="202.84,-619.7 194.76,-614.02 198.42,-618.85 194,-618 194,-618 194,-618 198.42,-618.85 193.24,-621.98 202.84,-619.7 202.84,-619.7"/>
<polyline fill="none" stroke="black" points="986,-571 981.5,-571.04 "/>
<polygon fill="black" stroke="black" points="980.56,-566.55 980.64,-575.55 978.84,-575.57 978.76,-566.57 980.56,-566.55"/>
<polyline fill="none" stroke="black" points="981.5,-571.04 977,-571.09 "/>
</g>
<!-- rental&#45;&gt;customer -->
<g id="edge18" class="edge">
<title>rental:customer_id&#45;&gt;customer:customer_id</title>
<path fill="none" stroke="black" d="M445.23,-506.89C492.68,-493.97 420.24,-372.82 467.89,-360.08"/>
<polygon fill="black" stroke="black" points="444.94,-506.92 435.51,-503.98 440.47,-507.46 436,-508 436,-508 436,-508 440.47,-507.46 436.49,-512.02 444.94,-506.92 444.94,-506.92"/>
<polyline fill="none" stroke="black" points="477,-359 472.53,-359.53 "/>
<polygon fill="black" stroke="black" points="471.11,-355.17 472.17,-364.11 470.38,-364.32 469.32,-355.38 471.11,-355.17"/>
<polyline fill="none" stroke="black" points="472.53,-359.53 468.06,-360.06 "/>
</g>
<!-- rental&#45;&gt;inventory -->
<g id="edge17" class="edge">
<title>rental:inventory_id&#45;&gt;inventory:inventory_id</title>
<path fill="none" stroke="black" d="M444.94,-538.35C459.89,-548.18 448.11,-585.82 463.06,-595.64"/>
<polygon fill="black" stroke="black" points="444.7,-538.29 437.03,-532.08 440.35,-537.15 436,-536 436,-536 436,-536 440.35,-537.15 434.97,-539.92 444.7,-538.29 444.7,-538.29"/>
<polyline fill="none" stroke="black" points="472,-598 467.65,-596.85 "/>
<polygon fill="black" stroke="black" points="467.93,-592.27 465.63,-600.97 463.89,-600.52 466.18,-591.81 467.93,-592.27"/>
<polyline fill="none" stroke="black" points="467.65,-596.85 463.3,-595.71 "/>
</g>
<!-- rental&#45;&gt;staff -->
<g id="edge16" class="edge">
<title>rental:staff_id&#45;&gt;staff:staff_id</title>
<path fill="none" stroke="black" d="M445.03,-454.03C546.1,-454.6 574.69,-465.02 678,-486 814.04,-513.63 842.73,-568.47 976.6,-570.92"/>
<polygon fill="black" stroke="black" points="445,-454.03 436.01,-449.95 440.5,-454.01 436,-454 436,-454 436,-454 440.5,-454.01 435.99,-458.05 445,-454.03 445,-454.03"/>
<polyline fill="none" stroke="black" points="986,-571 981.5,-570.96 "/>
<polygon fill="black" stroke="black" points="980.64,-566.45 980.56,-575.45 978.76,-575.43 978.84,-566.44 980.64,-566.45"/>
<polyline fill="none" stroke="black" points="981.5,-570.96 977,-570.92 "/>
</g>
<!-- staff&#45;&gt;address -->
<g id="edge20" class="edge">
<title>staff:address_id&#45;&gt;address:address_id</title>
<path fill="none" stroke="black" d="M1177.81,-487.45C1215.5,-462.33 1158.52,-259.79 1196.16,-234.57"/>
<polygon fill="black" stroke="black" points="1177.64,-487.5 1167.87,-486.11 1173.32,-488.75 1169,-490 1169,-490 1169,-490 1173.32,-488.75 1170.13,-493.89 1177.64,-487.5 1177.64,-487.5"/>
<polyline fill="none" stroke="black" points="1205,-232 1200.68,-233.26 "/>
<polygon fill="black" stroke="black" points="1198.56,-229.19 1201.07,-237.83 1199.34,-238.33 1196.83,-229.69 1198.56,-229.19"/>
<polyline fill="none" stroke="black" points="1200.68,-233.26 1196.36,-234.52 "/>
</g>
<!-- staff&#45;&gt;store -->
<g id="edge19" class="edge">
<title>staff:store_id&#45;&gt;store:store_id</title>
<path fill="none" stroke="black" d="M977.07,-406.1C961.02,-398.18 964.98,-367.82 948.92,-359.9"/>
<polygon fill="black" stroke="black" points="977.2,-406.13 985.16,-411.96 981.6,-407.06 986,-408 986,-408 986,-408 981.6,-407.06 986.84,-404.04 977.2,-406.13 977.2,-406.13"/>
<polyline fill="none" stroke="black" points="940,-358 944.4,-358.94 "/>
<polygon fill="black" stroke="black" points="944.34,-363.53 946.22,-354.72 947.98,-355.1 946.11,-363.9 944.34,-363.53"/>
<polyline fill="none" stroke="black" points="944.4,-358.94 948.8,-359.87 "/>
</g>
<!-- store&#45;&gt;address -->
<g id="edge22" class="edge">
<title>store:address_id&#45;&gt;address:address_id</title>
<path fill="none" stroke="black" d="M949.2,-301.68C965.15,-296.51 965.89,-277.55 986,-269 1074.01,-231.59 1104.39,-231.94 1195.94,-232"/>
<polygon fill="black" stroke="black" points="948.91,-301.72 939.42,-298.99 944.45,-302.36 940,-303 940,-303 940,-303 944.45,-302.36 940.58,-307.01 948.91,-301.72 948.91,-301.72"/>
<polyline fill="none" stroke="black" points="1205,-232 1200.5,-232 "/>
<polygon fill="black" stroke="black" points="1199.6,-227.5 1199.6,-236.5 1197.8,-236.5 1197.8,-227.5 1199.6,-227.5"/>
<polyline fill="none" stroke="black" points="1200.5,-232 1196,-232 "/>
</g>
<!-- store&#45;&gt;staff -->
<g id="edge21" class="edge">
<title>store:manager_staff_id&#45;&gt;staff:staff_id</title>
<path fill="none" stroke="black" d="M948.87,-333.7C984.41,-358.31 941.58,-543.8 977.16,-568.33"/>
<polygon fill="black" stroke="black" points="948.61,-333.62 941.18,-327.12 944.31,-332.31 940,-331 940,-331 940,-331 944.31,-332.31 938.82,-334.88 948.61,-333.62 948.61,-333.62"/>
<polyline fill="none" stroke="black" points="986,-571 981.69,-569.7 "/>
<polygon fill="black" stroke="black" points="982.13,-565.13 979.53,-573.74 977.81,-573.22 980.41,-564.61 982.13,-565.13"/>
<polyline fill="none" stroke="black" points="981.69,-569.7 977.39,-568.39 "/>
</g>
<!-- tmpCustomer -->
<g id="node17" class="node">
<title>tmpCustomer</title>
<polygon fill="none" stroke="black" points="11,-907 11,-928 183,-928 183,-907 11,-907"/>
<text text-anchor="start" x="49" y="-914.8" font-family="Helvetica,sans-Serif" font-style="italic" font-size="14.00">tmpCustomer</text>
<polygon fill="none" stroke="black" points="11,-880 11,-907 183,-907 183,-880 11,-880"/>
<text text-anchor="start" x="17" y="-890.8" font-family="Helvetica,sans-Serif" font-size="14.00">customer_id </text>
<text text-anchor="start" x="107" y="-890.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#999999">SMALLINT</text>
</g>
</g>
</svg>
@ckhung
Copy link
Author

ckhung commented May 2, 2021

Presently SQLParser does not support the BOOLEAN type. To save you some troubles, I have created and attached php pmysql.php ~/sakila-schema.sql > sakila.SQLParse.json so that you can skip the first step and start from python3 ~/json2erd.py -t xxx sakila.SQLParse.json

SQLParser now supports BOOLEAN. The large intermediate json file is no longer needed and therefore removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment