DbDiagram – Draw Entity-Relationship Diagrams, Painlessly
dbdiagram.io
dbdiagram.io
I'm generally a very "visual" person, but I've never found DB diagrams to be helpful for me. The problem is that when you get an even mildly complicated schema, things quickly become a morass of tons of intersecting relationship lines, and I just end up spending all my time trying to see how things are actually connected. I personally much prefer:
1. Just a simple, high-level textual description of the most important tables. Gives me a good "grounding" to start my investigation to understand the conceptual model.
2. Then, just a tree view of all the tables in a list, with their columns and indices underneath, basically the Database pane you get in DataGrip. It's very easy to see which columns are foreign keys so I can follow relationships to other tables if I want to, but it's not one giant, cluttered mass. I also always make use of Postgres COMMENTs on tables and columns, which will then display in DataGrip.
Don't mean to denigrate the team at all, and in fact another comment mentioned the same team did dbdocs.io, and a quick look at that site makes me think the "Table Structure" pane is very similar to what I've said I like above. Again, just curious if other folks find DB diagrams actually useful.
But also I found them useful as an onboarding tool: a single picture to describe the db, for eg. autogenerating them from the db FKs.
Granted, you can just look at the schema of each table, but having a single picture to look at will save some time and help memorizing the relationships.
As others have pointed out, I usually don't use them to try to get the big picture: you're right in it is a morass of over-lapping lines and tiny boxes. At the whole database view, the best you can hope for is finding certain "information clusters", places where many references cluster, that can get you to the major ideas implemented by the application; this is helpful sometimes when coming to an application you haven't encountered before. The more useful aspect is when you've already got a central table and you're trying to understand the closest relationships to that table: maybe directly related or one away. There are database diagramming tools that will allow you to pick a relation and then limit the diagram to those one away, two away sets of relationships. Of course manually just telling the tool to diagram only a particular subject area of the database at a time reduces the sense of noise in these diagrams and typically you're only really trying to understand the data structure of such a subset of the database at any one time anyway.
The open source diagramming tool I use is called SchemaSpy (https://schemaspy.org/). Its not a database design GUI or anything like that. It inspects an existing database and creates documentation based on what it finds. It does that "pick a relation and show me relationships a couple degrees of separation" thing.
I'd generate the db diagram for the small set of tables which my PR is touching, and highlight/annotate the changed columns/constraints (using ksnip) and attach it in the PR. It significantly reduced the back-and-forth between DBA/managers and sped up approval times.
I have not found it useful to understand the table structure or domain model (which in our case could be very complex) but for explaining some scoped change/proposal to people who already had domain familiarity it proved to be very useful.
E.g. mouse over a "Contact Information" and see "Person"/"Company" get highlighted as 2 entities that refer to "Contact Information"'s.
Personally, yes, although TBH I haven't tried them with DBs have hugely wide tables or a high number of tables.
> things quickly become a morass of tons of intersecting relationship lines, and I just end up spending all my time trying to see how things are actually connected.
So look at a "sub-diagram" - diagram of some of the tables.
> a tree view of all the tables in a list,
Just think of the diagram as that tree view and choose an arbitrary order of visitation of the nodes, e.g. Left-to-Right then Top-to-Bottom.
I would say, however, PlantUML is less pretty but more general as a tool and there are neat tools to make the diagrams directly from your database schema [0].
They have an option to take your SQL dump text and convert it back to DBML which is the DSL they use to render.
Never heard of DBML before... looks somewhat interesting.
Any other DB DSLs worth recommending?
Can you control the styling though? So you could embed it in a document with an existing style for diagrams?