2

I need to generate a pretty complex entity-relationship diagram, where visual design tools will not be convenient. I have many entities, some of which with up to 200 attributes.

So it would be easier to describe the database in plain text markup. Now, I did find one tool that seems to do it, but it's limited (you can't specify which fields relate two entities), and hasn't been updated in years.

Is there anything else available?

Thanks!

2

What you are looking for is GraphViz which already has many questions on this site.

It has been around for decades, is stable and well supported, and is generally the go to tool for generating all sorts of diagrams from text. Just take a look at the gallery.

If you Google, you will find many hits on GraphViv ERD, here are just a few:

shows how this code

digraph G { 
    //  
    // Defaults
    //  

    // Box for entities
    node [shape=none, margin=0]

    // One-to-many relation (from one, to many)
    edge [arrowhead=crow, arrowtail=none, dir=both]

    //  
    // Entities
    //  
    Article [label=<
        <table border="0" cellborder="1" cellspacing="0" cellpadding="4">
            <tr><td bgcolor="lightblue">Article</td></tr>
            <tr><td align="left">id: int(11)</td></tr>
            <tr><td align="left">author: int(11)</td></tr>
            <tr><td align="left">title: varchar(255)</td></tr>
            <tr><td align="left">content: longtext</td></tr>
            <tr><td align="left">created: datetime</td></tr>
            <tr><td align="left">modified: datetime</td></tr>
        </table>
    >]

    Comment [label=<
        <table border="0" cellborder="1" cellspacing="0" cellpadding="4">
            <tr><td bgcolor="lightblue">Comment</td></tr>
            <tr><td align="left">id: int(11)</td></tr>
            <tr><td align="left">author: int(11)</td></tr>
            <tr><td align="left">content: longtext</td></tr>
            <tr><td align="left">created: datetime</td></tr>
            <tr><td align="left">modified: datetime</td></tr>
        </table>
    >]  

    //  
    // Relationships
    //  
    Article->Comment;
}

generates this diagram

enter image description here

There are also a ton of options, if you have preferences.


You said of the previous tool which you found

it's limited (you can't specify which fields relate two entities)

This page shows a diagram which was created with GraphViz and does just that. It's SVG, so I can't embed it here, but you can see it on that page or as a standalone image here

The author also explains how he generated it. He also links to a great MS Visual Studio extension which shows you a live preview of the diagram as you code it.


And, finally, here's [a GitHub project](Translates a plain text description of a relational database schema to a graphical entity-relationship diagram.) which

Translates a plain text description of a relational database schema to a graphical entity-relationship diagram.

I am sure that you are answer is in there somewhere, and that will find many imaginative uses for GraphViz :-)

  • 1
    OK, thanks. I did know graphviz, but it's markup language is quite complex and was hoping for something simpler (ERD uses graphviz as its engine, but with a much simpler markup). I guess it will be worth investigating creating a small python script to generate the graphviz markup. – mrgou Sep 27 '18 at 17:30
  • Lol! One man's "complex" is another man's "powerful". I never thought of it as complex, but YMMV. Possibly that's because I do what you are contemplating, and generate it. Give it a try and let us know how it works out. – Mawg says reinstate Monica Sep 28 '18 at 6:58
0

Have you looked at graph theory software? I used Cytoscape for a project a few years ago and it's fairly user-friendly. It supports many standard formats.

More graph theory recommendations are available on Math.SE.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.