The tool looks very cool! But IMO you can't get an ER diagram from SQL since entities are fundamentally different from tables. They are certainly very similar, but SQL alone doesn't give you enough information to create an ER diagram.
That's not to say that the tool is useless or that diagrams of this sort are unhelpful. I'll admit I'm being pedantic and others will probably disagree.
> 100/10 for mobile usability. Panning, Zooming, selecting and moving was so seamless I thought I was tripping out.
Yeah, my first thought was that the diagramming bit needs to be ripped out into its own library, because I can see a use for the diagramming bits for more than ER diagrams.
Author is top notch in my book. I'm a sucker for someone taking a complex problem and distilling out a simple solution. I don't know of higher praise to give a developer.
A few years ago I created a similar layout engine, it was extremely janky when I abandoned it because I first wanted to solve order/placing of the tiles but was unable to figure out a good algorithm for it
Eg your example diagram has an optimal order in which there are no overlapping lines... But it's surprisingly hard to figure that out without doing n^m calculations... And I wanted to use it in a game, so a shitton of tiles.
Dunno where I was going with this, just got reminded of that project after looking at this great implementation.
It's a small too nothing great I just figured others might find it useful too. I kept finding myself needing to visualize database schemas, but most tools had the same problems: paywalls, mandatory signups, or sending your SQL to someone else's server.
No backend, no accounts, no data leaving your machine.
A few implementation details that were fun:
* Built on <canvas> instead of DOM/SVG. Tables are rasterized into cached bitmaps with viewport culling, which keeps things smooth even with hundreds of tables on screen.
* The SQL parser tracks source spans for every token. That lets edits stay surgical so a rename a table and only the relevant identifier (and its references) change while comments and formatting remain untouched.
* The URL contains the entire schema. Sharing simply serializes the schema into the URL itself, so there's no backend, no stored state, and no account required.
* I also experimented with a Rust/WASM version because why not? but the parser was ~37% slower because the JS↔WASM boundary cost outweighed the compute savings but The O(n^2) overlap-resolution pass was about 2.2x faster though * In the end I stuck with plain JavaScript. No framework ~32KB gzipped
Probably not that important in practice. Firefox allows 2^20 - 4 and Chrome allows 2100000 characters. Also, 8000 characters already allows for an unreasonable amount of SQL and could be extended even further with compression. And if that should not be enough, the website already supports JSON exports. All in all, this seems like a worthwhile tradeoff for not having to store anything.
DBeaver does a good job of this and works with most databases. I would not use MySQL Workbench or PGAAdmin now.
This might be a good implementation but is it not easier to use something that can connect to your database than having to copy and paste chunks of SQL?
Just to clarify, what link is it?
I've check it out, and the GitHub icon, in the header on the top right corner, is correct, and links to the following project:
- https://github.com/royalbhati/sqltoerdiagram
I kept finding myself needing to visualize database schemas, but most tools had the same problems: paywalls, mandatory signups, or sending your SQL to someone else's server.
So I ended up building my own.
You paste in your CREATE TABLE statements and it generates an interactive ER diagram right in the browser. You can drag tables around, auto arrange the layout, edit table/column names directly on the canvas (it rewrites the SQL for you), add notes and group boxes, and export as PNG or SVG.
No backend, no accounts, no data leaving your machine.
A few implementation details that were fun:
* Built on <canvas> instead of DOM/SVG. Tables are rasterized into cached bitmaps with viewport culling, which keeps things smooth even with hundreds of tables on screen.
* The SQL parser tracks source spans for every token. That lets edits stay surgical so a rename a table and only the relevant identifier (and its references) change while comments and formatting remain untouched.
* The URL contains the entire schema. Sharing simply serializes the schema into the URL itself, so there's no backend, no stored state, and no account required.
* I also experimented with a Rust/WASM version because why not? but the parser was ~37% slower because the JS↔WASM boundary cost outweighed the compute savings but The O(n^2) overlap-resolution pass was about 2.2x faster though
* In the end I stuck with plain JavaScript. No framework ~32KB gzipped
It's a small too nothing great I just figured others might find it useful too.
(Only minor tweak one could suggest would be multiple table selection for dragging... but to quote Frasier: "Think about it, Niles. What's the one thing better than an exquisite meal? An exquisite meal, with one tiny flaw we can pick at all night." Niles, raising a glass: "Ah, of course, to impossible standards.")
That's not to say that the tool is useless or that diagrams of this sort are unhelpful. I'll admit I'm being pedantic and others will probably disagree.
reply