Do you like this? (PUML fom Schema)

0 votes
asked Feb 17, 2021 in Question / help by bruss (120 points)


I started a SQL script to convert an MS SQL database schema to plantuml source. The git repo is public if you'd like to try it. Details in the readme.This is the output from the Microsoft pubs database at the moment.

I guess a similar technique could be used for MySQL etc.

pubs db

commented Feb 24, 2021 by chris (2,580 points)

I like it! If I may, I have been having a play with the json preprocessing with a similar goal. I was thinking this would work well from a json definition.
For example most databases will allow you to get a result set as a json response, instead of tabulated data - and all use the standard INFORMATION_SCHEMA to detail the table metadata. Therefore, I think it would be possible to separate the puml code from the "get me the database" code, using json as the intermediary. You can then use a standard styling and work for all databases, provided you can get a SQL query to output the expected json structure.

For example, here is a demo diagram with some attribute annotations you could use for things like primary keys, I have also popped some annotation on the tables and links so you can explore the database without a cluttered diagram.

This example combines a few ideas, change the "svg" in the above link to "uml" to view the source

1 Answer

0 votes
answered Feb 24, 2021 by anonymous

That's great! Didn't know you could do that so thanks for sharing. Since the original post I rewrote it in Python with pyodbc, but this may be even better. Python has great JASON handling

Found a good article on the JSON processing at mssqltips might be an idea to test it with MySQL etc as that was going to be my next test with my pyodbc code.