Make sure you have graphviz
, libtool
installed.
To do that you can use homebrew
:
brew install graphviz libtool
sudo apt install graphviz libtool openjdk-8-jre-headless
You will need JRE 8 installed as well.
You can use this to generate a visual representation of your local database.
It has the following assumptions:
- your database is
PostgreSQL
- you have a
postgres
user with no password set there - the database runs on port
5432
atlocalhost
- it has a default schema called
public
If you want to modify any of the above setting, you can change visualize.sh
file.
To generate a GUI for your database you can use:
./visualize.sh DATABASE_NAME [OUTPUT_DIRECTORY]
Keep in mind that OUTPUT_DIRECTORY
is optional and its default is the same as DATABASE_NAME
.
There are some convenient scripts predefined for already existing projects which have database name and output directory provided.
The entry point to generated results is OUTPUT_DIRECTORY/index.html
. It looks as follows:
which lists all of the tables involved in relationships.
which includes:
- foreign keys
- child/parent tables
- deletion rules
which represents relations themselves (with optional columns to see).
Which are basically all tables that are not connected with antyhing else. They are not involved in the relations above.
Lucidchart
has an awesome feature of importing CSV generated schemas and generating tables that are ready to be placed on the canvas.
To get an appropriate CSV file you can execute
./generate_csv_schema.sh DATABASE_NAME [OUTPUT_FILE]
- Create a new Lucidchart document
- Press more shapes button in the bottom left corner
- Tick Entity Relationship checkbox
- Click Save
- In the left pane in Entity Relationship section select import.
- Click Choose file button and point to the generated CSV file.
- Click OK
- Once imported, all tables should be visible in left pane under
PROJECT_NAME
section - You can drag and drop them to a canvas
- After you have all tables in your documents, you can organize them as you wish
--
The result is a .csv
file that can be imported and used in Lucidchart
directly.
After running a script you will find it as:
./OUTPUT_FILE.csv
Feel free to add new scripts for any other project you need.