News for hackers. Stuff that matters.

Show HN: Visualize database schemas with a single query

https://github.com/chartdb/chartdb

Hey HN! We are Jonathan & Guy, and we are happy to share a project we’ve been working on. ChartDB is a tool to help developers and data analysts quickly visualize database schemas by generating ER diagrams with just one query. A unique feature of our product is AI-Powered export for easy migration. You can give it a try at https://chartdb.io and find the source code on GitHub. Next steps ---> More AI. We’d love feedback :)
( 64 comments | 73 points | on HN )
Re:Show HN: Visualize database schemas with a single query by djray on Saturday August 24, 2024 @01:51PM (#41339966)
I rather think using AI to generate scripts for other DBs is a disadvantage. Scripting is a deterministic process, surely? Can you create a common internal representation and write exporters for each supported DBMS from that? Maybe the JSON format you use is a path toward this.

I dislike the multiple references to 'Magic' on the site, but I realise that's probably a subjective thing. Maybe I'm fatigued by the AI-in-everything trend.

I don't use all the DBMSes you support, but I'm not sure having a single query to run is really much of a selling point. For SQL Server, I'd rather execute a stored procedure with permission checks, and progress feedback, than a big chunk o' SQL. (Again, that may just be a me thing.) If it's an efficiency thing for very large DBs then I think you should emphasise that, and also detail how much faster it is to gather all the info in one fell swoop than if you split up the queries.

The Examples link is currently broken on your site, btw. That sounds like a really useful way that people can evaluate your application without having to run a query on their own DB, which they may be reticent to do for testing out a new app.

Re:Show HN: Visualize database schemas with a single query by Jonathanfishner on Saturday August 24, 2024 @05:18PM (#41341597)
Thanks for the feedback! We aimed to make database migration easier and found that AI could really enhance this process by handling the complexities of different DB dialects. We'll also explore more deterministic approaches, as you suggested, using a common internal representation. The "Examples" link is being fixed—thanks for catching that!
Re:Show HN: Visualize database schemas with a single query by teleforce on Saturday August 24, 2024 @10:44PM (#41343914)
Not a database expert but CUE can be used for generic schema design and validation, maybe it can also be used for deterministic database schema extraction and migration [1].

Unlike AI's non-deterministic techniques for example LLM approaches to NLP, CUE utilizes a well established alternative NLP deterministic approach namely Feature Structure [2], [3].

[1] Cue – A language for defining, generating, and validating data:

https://news.ycombinator.com/item?id=20847943

[2] Feature structure:

https://en.m.wikipedia.org/wiki/Feature_structure

[3] The Logic of CUE:

https://cuelang.org/docs/concept/the-logic-of-cue/

Re:Show HN: Visualize database schemas with a single query by RadiozRadioz on Sunday August 25, 2024 @11:14AM (#41347862)
The different dialects have complexities, but they are they are known and explicitly defined. This task is natural to solve deterministically, and I'd say it's also important to do so - accuracy and consistency are paramount when migrating. I am having an extremely hard time understanding what benefits AI has here over a simple transpilation approach.

Two benefits coming to mind are that AI is a good buzzword, and "shove it into ChatGPT, that'll do" takes less effort than building a proper transpiler.

Re:Show HN: Visualize database schemas with a single query by bal00ns on Sunday August 25, 2024 @09:05PM (#41353001)
Like you said I imagine it was less effort. Less effort can be very valuable if you’re still producing something useful. Perhaps you could use a simple transpilation approach yourself if you think that’s a good idea.
Re:Show HN: Visualize database schemas with a single query by rustman123 on Saturday August 24, 2024 @03:45PM (#41340909)
"PostgresSQL"? "SQL Lite"? Not even getting the names of the supported databases right doesn’t create trust…
Re:Show HN: Visualize database schemas with a single query by doctorpangloss on Saturday August 24, 2024 @05:53PM (#41341950)
On the other hand, the chatbots let enthusiasts like these guys write code. There are millions of them. And each of them, even if they are 1/2 as good as you rustman123, for starters they will learn the right names for things, that’s not challenging, and secondly, they have more time than you have for this problem, which you have zero.

The chatbots are the Zero to One for programming.

So listen I agree with you. I’m not going to use this. But hundreds of thousands of smart people with time, like these guys, can now author stuff that will get better over time faster than you personally will solve any one particular problem for anyone. So something something, log in your own eye before the thorn in the other.

Re:Show HN: Visualize database schemas with a single query by jkcorrea on Sunday August 25, 2024 @01:14AM (#41344587)
idk why you’re getting downvoted. you’re absolutely right and not disparaging in any way. sometimes hn can’t see the forest for the trees…
Re:Show HN: Visualize database schemas with a single query by wesammikhail on Sunday August 25, 2024 @07:32AM (#41346499)
> The chatbots are the Zero to One for programming.

This would make Peter himself cringe let alone the rests of us.

That said, if you really believe this, I've got an AI product to sell you. It's the Zero to One for anything you want. It's called HypeLLM.

Re:Show HN: Visualize database schemas with a single query by thesnide on Tuesday August 27, 2024 @02:56AM (#41365138)
given enough monkeys typing, we would have the greatest novel of all kinds.

This is true. In theory. In practice, the real struggle is to find the gem in an ocean of garbage.

Something that cannot be found simply doesn't exists for any practical terms.

Nature has a way to triage its sheer numbers of genetic permutations : wastness of the world and mostly infinite time.

Re:Show HN: Visualize database schemas with a single query by zx8080 on Saturday August 24, 2024 @11:14PM (#41344051)
We are entering into an era of AI-generated programs. Brace yourself and enjoy the shitshow.
Re:Show HN: Visualize database schemas with a single query by ok123456 on Saturday August 24, 2024 @02:40PM (#41340391)
How is this different from Schema Spy (https://schemaspy.org)?
Re:Show HN: Visualize database schemas with a single query by layer8 on Saturday August 24, 2024 @04:23PM (#41341205)
It supports fewer databases. ;)
Re:Show HN: Visualize database schemas with a single query by callumgare on Saturday August 24, 2024 @07:19PM (#41342704)
A big one for me is that it generates a nice interactive UI with the ability to zoom and reorganise tables rather than a static image. I find with sufficiently complex projects it becomes a real pain to navigate a exported image.
Re:Show HN: Visualize database schemas with a single query by ok123456 on Saturday August 24, 2024 @08:15PM (#41343097)
Schema Spy generates graphviz files. You could render those in the browser.
Re:Show HN: Visualize database schemas with a single query by breadwinner on Saturday August 24, 2024 @08:49PM (#41343326)
Or use a tool that already does the rendering, with zoom and pan: https://visualdb.com
Re:Show HN: Visualize database schemas with a single query by ok123456 on Sunday August 25, 2024 @01:20PM (#41349182)
Or, generate an SVG from the dot file and pan and zoom like any other SVG file in the browser.
Re:Show HN: Visualize database schemas with a single query by breadwinner on Sunday August 25, 2024 @08:10PM (#41352695)
Then you won't be able to click on a table to view details in a popup.
Re:Show HN: Visualize database schemas with a single query by webprofusion on Saturday August 24, 2024 @10:14PM (#41343762)
Hmm, the obvious difference is that it's a completely different tool that does a completely different job.
Re:Show HN: Visualize database schemas with a single query by ok123456 on Sunday August 25, 2024 @01:19PM (#41349169)
How is it an "obvious" difference that it's a "completely" different tool that does a "completely different" job? Both tools generate diagrams from existing databases.
Re:Show HN: Visualize database schemas with a single query by andrelaszlo on Saturday August 24, 2024 @01:00PM (#41339575)
> visualize database schemas by generating ER diagrams with just one query

> visualize and design your DB with a single query

> Instantly visualize your database schema with a single "Smart Query."

The tool seems really useful and I will give it a try!

Just curious about the emphasis on the single query. What's the value of this? If it makes it much faster than similar tools it's probably worth making it explicit. I don't use them often enough to know if speed is a big issue (if this is the reason).

Nice work anyway!

Re:Show HN: Visualize database schemas with a single query by croes on Saturday August 24, 2024 @03:31PM (#41340802)
>Just curious about the emphasis on the single query.

Marketing?

And they need a single json to create the diagram from.

Re:Show HN: Visualize database schemas with a single query by SoftTalker on Saturday August 24, 2024 @01:17PM (#41339698)
They are querying postgres information_schema tables (or their equivalent in the other supported databases) to get table names, column names and types, foreign keys, etc.

I doubt the "single query" makes it immensely faster, but reducing query round-trips is usually time-saving. Might be noticable, depending on what you're comparing it to.

Re:Show HN: Visualize database schemas with a single query by hackernewds on Saturday August 24, 2024 @02:42PM (#41340408)
does it necessitate foreign keys and schemas being defined beforehand? or is that the "AI magic"?
Re:Show HN: Visualize database schemas with a single query by croes on Saturday August 24, 2024 @03:28PM (#41340773)
It has to be in defined beforehand.

No AI magic can know the foreign keys from the schema alone and even with data the results would be uncertain.

Re:Show HN: Visualize database schemas with a single query by scotty79 on Saturday August 24, 2024 @06:57PM (#41342518)
If you are naming your foreign key fields consistently for example extras.products_id -> products.id or using some fairly unique data type like GUID for your keys it could be intelligently inferred.
Re:Show HN: Visualize database schemas with a single query by croes on Sunday August 25, 2024 @02:27AM (#41344910)
Still lots of hits and misses.

Column names could sound like foreign keys on pure chance and the data type doesn't show which other table it's referring to.

Re:Show HN: Visualize database schemas with a single query by parpfish on Sunday August 25, 2024 @12:24PM (#41348547)
If you’re allowed to query the data you could use the column name/data type to come up with lots of good candidates, and then if then verify by checking whether the actual values correspond (assuming that it’s something like a uuid or username column and not a serial/int column)
Re:Show HN: Visualize database schemas with a single query by lolive on Sunday August 25, 2024 @03:46AM (#41345310)
Newbie here. How do you express foreign key - primary key relationships when you define your schema, in Postgresql and/or SQLServer ? Is it via an integrity constraint, or can it be just an informative metadata ?
Re:Show HN: Visualize database schemas with a single query by parpfish on Sunday August 25, 2024 @12:25PM (#41348555)
I’m curious how frequently people actually encounter foreign key constraints in production.

I’m 10 years in and have only ever seen it once

Re:Show HN: Visualize database schemas with a single query by Jonathanfishner on Saturday August 24, 2024 @05:29PM (#41341684)
Thanks for the feedback! The emphasis on a single query highlights how easy it is to import your database schema: just run the query, get the JSON output, and start editing your diagram in ChartDB. Plus, there’s no need to sign in or set your database credentials. It’s all about simplifying the process and saving time so you can get started quickly. Speed is a bonus, but the main value is the simplicity and ease of use. Glad you're giving it a try!
Re:Show HN: Visualize database schemas with a single query by andrelaszlo on Saturday August 24, 2024 @05:36PM (#41341752)
Not requiring db credentials is a huge plus! Thanks for the explanation.
Re:Show HN: Visualize database schemas with a single query by yetanotherdood on Saturday August 24, 2024 @03:03PM (#41340574)
I think having multiple "views" of these diagrams would be nifty. In addition to the standard visualization, you could have an "index" visualization that also captures foreign keys etc.
Re:Show HN: Visualize database schemas with a single query by jesperwe on Saturday August 24, 2024 @02:41PM (#41340395)
I tried it out on a not so complex Postgres v15 DB. No relations were imported, just the tables?
Re:Show HN: Visualize database schemas with a single query by Jonathanfishner on Sunday August 25, 2024 @08:38AM (#41346878)
Thanks for giving it a try! I just tested it on an RDS PostgreSQL 15.4 instance, and it worked on my end. Would you mind opening a GitHub issue so we can dig into this further and help resolve it? Your input will be really helpful in fixing the issue.
Re:Show HN: Visualize database schemas with a single query by ellyagg on Saturday August 24, 2024 @02:43PM (#41340411)
Awesome! This is exactly what I wanted last year when I was helping my wife with her reporting and the only access she had to her company's application database was through Redash.
Re:Show HN: Visualize database schemas with a single query by namanyayg on Saturday August 24, 2024 @12:48PM (#41339497)
nice work on chartdb, guys!

can you elaborate on how the ai part works? im a bit confused how that fits in because there are many SQL diagram tools without AI as well

Re:Show HN: Visualize database schemas with a single query by Jonathanfishner on Saturday August 24, 2024 @01:41PM (#41339886)
Thank you! We use GPT-4o to generate database schema creation scripts for different database dialects. Basically, we wanted to add the option to export the db schema to any type of database (for easy Migration for example from MySQL to PostgreSQL or from SQLite to MariaDB). First, we tried to implement that logic, after getting into trouble with too many different edge cases and dialect differences between different databases we decided to leverage AI in order to achieve that.
Re:Show HN: Visualize database schemas with a single query by yardstick on Saturday August 24, 2024 @07:20PM (#41342722)
> after getting into trouble with too many different edge cases and dialect differences between different databases we decided to leverage AI in order to achieve that.

So you identified all the issues in your code generation, decided instead of fixing them to use ChatGPT instead, and trust that ChatGPT did it correctly?

Are you saving much effort? Are you providing an accurate, bug free experience for all the SQL databases you claim to support?

Re:Show HN: Visualize database schemas with a single query by gitroom on Saturday August 24, 2024 @01:01PM (#41339587)
This is cool, but there are a lot of visualizer, what's the difference?
Re:Show HN: Visualize database schemas with a single query by Jonathanfishner on Saturday August 24, 2024 @05:24PM (#41341646)
Thank you first of all! ChartDB stands out with its one-query for visualization, AI-powered migration for easy cross-DB transitions, and interactive editing, all free and open-source, combining these features in a user-friendly way.
Re:Show HN: Visualize database schemas with a single query by SahAssar on Saturday August 24, 2024 @06:58PM (#41342519)
I'm not sold on many of those points, but "AI-powered migration" stood out to me (as something that seems like a risky idea with many unknown consequences). What do you mean by that and how would it be deployed?
Re:Show HN: Visualize database schemas with a single query by nerdponx on Sunday August 25, 2024 @04:31AM (#41345576)
This product seems primarily like a solution looking for a problem to solve. The rare team that actually needs this will probably only need it on a one-off basis, and so will probably hack it together ad-hoc or hire a consultant to do it. Perhaps the target market should be unscrupulous contractors.
Re:Show HN: Visualize database schemas with a single query by samstave on Saturday August 24, 2024 @02:17PM (#41340191)
huh.. I like to have claude give me a DB schema in a mermaid diagram, infact - I make python scripts to log into the DB, list the DBs, list the schemas, and make a mermaid diagram of the schema and then I have a python script that converts the mermaid code to an SVG.
Re:Show HN: Visualize database schemas with a single query by hackernewds on Saturday August 24, 2024 @02:43PM (#41340412)
what is your input to Claude
Re:Show HN: Visualize database schemas with a single query by salzig on Saturday August 24, 2024 @06:11PM (#41342132)
> STRING_AGG aggregation result exceeded the limit of 8000 bytes. Use LOB types to avoid result truncation.

Looks like not all databases (mssql in this case) like the generated result.

Re:Show HN: Visualize database schemas with a single query by Jonathanfishner on Saturday August 24, 2024 @07:20PM (#41342715)
Thank you for catching that issue with the STRING_AGG limit! I just pushed a fix that now supports nvarchar(max) to avoid truncation. This should resolve the issue with large outputs in MSSQL. If you still encounter any problems, please let me know. I'd love for you to give it another try and see if everything works as expected now. Your feedback is invaluable!
Re:Show HN: Visualize database schemas with a single query by salzig on Sunday August 25, 2024 @08:23AM (#41346805)
now it kills the process (dev env, container).

Not sure what kills it, but without "columns" in "full_json_result" it runs through.

Re:Show HN: Visualize database schemas with a single query by Eji1700 on Saturday August 24, 2024 @06:17PM (#41342171)
Yeup. Seconded. MSSQL as well. Was curious what the output would look like given it's a fairly large db (a crap ton of mostly useless tables kept for archival purposes).
Re:Show HN: Visualize database schemas with a single query by zola on Saturday August 24, 2024 @08:07PM (#41343035)
Is there a tool with similar presentation, but for database records and not schema? So I could "select * from product where id=5" and it would show me Product card for "hammer" and related card for Brand "ACME", and other related records which might be many/one to one/many relationship etc. In other words - data exploration tool with diagramming like in here?

I just asked chatGPT for this, but human perspective would be great :)

Re:Show HN: Visualize database schemas with a single query by webprofusion on Saturday August 24, 2024 @10:12PM (#41343753)
Not bad! Could do with a layout option so the relations are easier to see.

The OG of DB table designers is the SQL Server database diagrams feature, and before that MS Access, and there is still room for improvement in this tool. Obviously saving changes back to your db (and migration scripts) is the most important feature, git tracking of schema changes would be good.

Re:Show HN: Visualize database schemas with a single query by qwertydog on Saturday August 24, 2024 @10:17PM (#41343780)
Just checked out the MS SQL script. I believe it's vulnerable to SQL injection via table/column/view/index/schema names (however unlikely that may be). You might want a disclaimer not to run the script with object names that could be user provided (especially as a privileged user)
Re:Show HN: Visualize database schemas with a single query by Jonathanfishner on Sunday August 25, 2024 @08:37AM (#41346874)
Thanks for pointing that out! Just to clarify, we provide a single, hardcoded query that fetches metadata, with no option for user input. The user only needs to take the generated JSON and use it in a React app that they can also run locally. Since there's no user input involved, SQL injection shouldn't be a concern here. If you see any specific risks, though, I’d love to hear more!
Re:Show HN: Visualize database schemas with a single query by qwertydog on Sunday August 25, 2024 @09:49AM (#41347305)
Ah sorry my bad, I should have read the full script. The script fails though if object names contain double quotes e.g. https://dbfiddle.uk/y-C6Da07
Re:Show HN: Visualize database schemas with a single query by Jonathanfishner on Sunday August 25, 2024 @03:29PM (#41350487)
Thanks for catching that! I’ve fixed it for you here: https://dbfiddle.uk/F2vuGKVS. I also tested the export script with a table name like "table", and it worked. If you don’t mind, could you open an issue in our repo? I’ll work on pushing a full fix today.
Re:Show HN: Visualize database schemas with a single query by qwertydog on Sunday August 25, 2024 @08:34PM (#41352800)
Just saw this. I see you've already pushed a fix on GitHub thanks. I can't see object ID's being included in the script, so I assume multiple objects with similar names will all be treated as the "same" object e.g. https://dbfiddle.uk/O_yZLjpN
Re:Show HN: Visualize database schemas with a single query by ahaapple on Saturday August 24, 2024 @11:00PM (#41343997)
I am curious about what great role AI can play in the chartdb project?
Re:Show HN: Visualize database schemas with a single query by idorube on Sunday August 25, 2024 @04:11AM (#41345459)
There's a typo on your "Quick Start" button. ("Quck Start")
Re:Show HN: Visualize database schemas with a single query by 1ilit on Sunday August 25, 2024 @04:51AM (#41345674)
Reminds me a lot of my drawDB: https://www.drawdb.app/. *Not a shameless plug, actually*
Re:Show HN: Visualize database schemas with a single query by azophy_2 on Wednesday August 28, 2024 @12:54AM (#41376077)
actually both projects looks incredibly similar. perhaps both using the same UI framework or something?
Re:Show HN: Visualize database schemas with a single query by amenghra on Sunday August 25, 2024 @05:11AM (#41345777)
Re:Show HN: Visualize database schemas with a single query by clidey on Sunday August 25, 2024 @02:23PM (#41349801)
Hey this is really cool! I love how sleek the interface is. We're doing something similar at WhoDB (https://github.com/clidey/whodb) and love seeing all the work happening in this space.

Congrats on the launch and happy building!

Disclaimer: I'm one of the cofounders of WhoDB.

Re:Show HN: Visualize database schemas with a single query by yencabulator on Monday August 26, 2024 @03:01PM (#41360525)
Constructing JSON by hand is not a good idea: https://github.com/chartdb/chartdb/blob/66db34d9114104aaaafa...
Re:Show HN: Visualize database schemas with a single query by jalopy on Wednesday August 28, 2024 @07:48AM (#41378473)
This is great. Anyone know how hard it would be to adapt to Athena?