Drawing Entity Relationship Diagrams with Stable Diffusion

Humor
5 Comments

Documenting your database and code is such a pain in the rear. Wouldn’t it be awesome if artificial intelligence could help?

Good news! There are a bunch of AI systems like Stable Diffusion and DALL-E that will draw things based on your text prompts. Forget the slow, tedious task of sketching out the relationships between your tables, and let the machines do the hard work for you.

For examples, give this prompt to Stable Diffusion: entity relationship diagram, database, microsoft, sql server, table, unreal engine, ultra realistic

In the interest of speed, I’m only generating 512×512 pixel images, but… I tell you what, if I wanted to pull a joke on a project manager, it’d be pretty funny to generate a whole folder of high-resolution ones, print them out, and gesture at them as I quickly flip through the pages, saying, “We’ve done a spectacular amount of work documenting our database, the application, and its process flows.”

That’s all well and good, but … I think we can do better.

Thomas Kinkade’s Database Diagrams

Why not turn our database diagrams into something our parents would be proud to frame and hang on their walls? I mean, the Painter of Light is not my thing, but he brings a certain something to our databases.

prompt: entity relationship diagram!!!, database, art by thomas kinkade

He really brings our documentation to life. Our databases and apps are often a lot like trees – insert dead wood joke here, ha ha ho ho.

What if your style is a little more tech modern? I got you, fam.

Anime Database Diagrams

prompt: entity relationship diagram!!, database, art by greg rutkowski and wlop and artgerm

Right? RIGHT?!? That is bad ass. Now THAT is the kind of database documentation I actually wanna read. I want that on a poster in my office. I want that as a poster in my BEDROOM.

But sometimes, you’re working with an application that’s a little more… creative.

Salvador Dali’s Database Diagrams

Ever wonder how the surrealist painter would diagram out the relationships between his tables? Me too. I think about it all the time. It’s time to answer that vital question.

Prompt I used: entity relationship diagram, database, salvador dali, surreal

   

I hereby call on ERStudio to add Salvador Dali filter. This is what the world needs today.

Too much for you? Want to ease things up a little?

Super Mario’s Entity Relationship Diagrams

I used a variety of prompts for these – it took a lot of experimentation because Stable Diffusion kept trying to just show Mario on top of diagrams, which wasn’t really what I wanted:

I think… that last one is a representation of Super Mario as … a database architect? That’s wonderful, and it sent me down another rabbit hole:

Prompt: super mario holding an entity relationship diagram printout in his hand

This is a wonderful fantasy world – however, let’s get back to today. Let’s find out more about the kinds of folks who have to work with this documentation.

Database administrator at work

Prompt I used: database administrator at work in the office, unreal engine, ultra realistic

 

Oof: welcome to biased artificial intelligence. If the model is trained on images and data that are mostly white males, and if you’re not specific about the subject of the art, then guess what kind of output you’re going to get? All white males with facial hair.

If you specifically *ask* for diversity, you can get it, but it’s up to you to do that. For example, if you prefix that prompt with “minority female”, then you get:

But again, if you want more diversity than that, you have to be more specific and ask for things like specific races. <sigh> Bias in artificial intelligence is a big issue, something scientists will be working on for the years to come. I just feel like I can’t talk about AI-generated images without at least mentioning that topic.

How to generate images yourself

Database administrator?

There are a bunch of cloud-based AI illustration tools like DALL-E, but most of them cost money or limit you to a certain number of attempts per day. I say “attempts” because a lot of times, when you put in a prompt, you’re not going to get an image you’re happy with. For example, if you just prompt “database administrator”, you get racks of servers in a data center.

It’s going to take a lot of attempts to get the kind of output you’re looking for. Therefore, I wanted to run it locally on my own laptop to get unlimited attempts with quick turnarounds.

Here’s what I used:

  • NVidia graphics card with at least 6GB RAM – I’m using my gaming laptop, an Asus Zephyrus with an RTX 3060 and 6GB RAM. 512×512 pixel images generate in about 20 seconds.
  • Stable Diffusion GRisk GUI 0.1 – free Windows app based on the open source Stable Diffusion, but requires no knowledge of how any of this stuff works. It just works, out of the box. 3GB download, requires about 7GB of drive space. Danger: this GUI is a closed source app from a stranger, and no verifiable way to reproduce it, which means it could be doing anything, like malware or mining Bitcoin. If you’re willing to roll up your sleeves, there are safer but more complex ways to run it.
  • Stable Diffusion prompting cheatsheet – if you just put in “database administrator”, you get garbage. You need to be as descriptive as possible, and that’s where prompt engineering comes in. For much more details, check out the Stable Diffusion Akashic Records.
  • Lexica.art – examples of generated art, AND – here’s the important part – the prompts that created them. (The prompts are on the left – that’s not immediately obvious.)
  • /r/StableDiffusion – extremely active SubReddit.

I played around with Stable Diffusion a lot this weekend, and it’s incredibly addictive. The biggest problem by far is that you’re going to have an idea, put that prompt in, and say to yourself, “Well, that’s interesting… but if I just change a few keywords, I can make it way better.” And then next thing you know, an hour has gone by.

Here’s how my workflow goes:

  • Start with a set of keywords, and generate a bunch of images (like say 10 or 50.)
  • Find the ones you like, and note their seed numbers. Normally, Stable Diffusion takes -1 as a seed, which means generate a random seed. However, if you pass a specific seed number in again, but tweak your keywords the second time around, you can modify that image. For example, you can change the art style, or refine the keywords to make that image better represent what you’re looking for.

Happy playing! Did I say playing? I meant documenting. Yeah. You’re doing important research.

Previous Post
PSPO: How SQL Server 2022 Tries to Fix Parameter Sniffing
Next Post
SQL ConstantCare® Population Report: Summer 2022

5 Comments. Leave new

  • The data model for our business processes would require a Rube Goldberg theme.

    Reply
  • The AI needs work, none of the DBA’s are sleeping.

    Reply
  • Stable Diffusion & ChatGPT are to society what DB corruption is to a relational database…

    One day, we’ll look back and wonder just how long as this been scribbling nonsense on the storage media of our shared brain. Someone will rush to restore a backup, but the documentation for doing so will have been revised by a ChatGPT version.

    Alice will wave a seven fingered hand at us just as the Cheshire Cat’s eighty tooth smile fades away.

    Reply
    • HA! Yeah, that’s why Stack Overflow had to ban AI-created answers. They *sounded* right at first glance, and would be enough to fool people, but then they wouldn’t survive deeper examination.

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.