question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Connect tables with foreign keys when inserting from SQL Script

See original GitHub issue
  • I agree to follow the Code of Conduct that this project adheres to.
  • I have searched the issue tracker for a feature request that matches the one I want to file, without success.

Is your feature request related to a problem? Please describe. /pull/233 It would be nice to have diagram tables connect to each other when they have foreign keys defined when adding via a sql script.

Describe the solution you’d like So to begin with, there is a bit of confusion if you look at the pull request listed above. There is the SQL import plugin, and a SQL import baked into Draw.io. Neither of these support linking foreign keys between tables currently. The sql server example from the SQL import plugin looks about the closest right now, so I’m basing my example off of that.

Following these clicks produces result shown as 5: image

Preferred output: image

Notice the addition of the directional connector from one row to the other to indicate the relationship.

Describe alternatives you’ve considered https://github.com/dbeaver/dbeaver/issues/7067 Exporting from an existing diagramming software to graphml and then importing into draw.io.

Additional context The existing advanced option (arrange, insert, advanced, from sql) for importing does not support this type of script and produces strange output: image Note that I used the same script as above except for adding a primary key to the personID.

CREATE TABLE Persons
(
PersonID int primary key,
LastName varchar(255),
FirstName varchar(255),
Address varchar(255),
City varchar(255)
);

CREATE TABLE Orders (
    OrderID int NOT NULL,
    PRIMARY KEY (OrderID),
    CONSTRAINT FK_PersonOrder FOREIGN KEY (OrderID)
    REFERENCES Persons(PersonID)
);

This could possibly be considered a separate bug, but it just seems strange that the plugin supports more than the one integrated into the core application, although in my opinion the core’s output is more visually appealing especially since it includes data types.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
davidjgraphcommented, Dec 15, 2021

No, I’ll close to reflect this.

0reactions
kddsultancommented, Jun 15, 2022

Would be great to see the feature grow further. @davidjgraph, how could a potential contributor like me would be helpful here?

Read more comments on GitHub >

github_iconTop Results From Across the Web

SQL FOREIGN KEY Constraint - W3Schools
A FOREIGN KEY is a field (or collection of fields) in one table, that refers to the PRIMARY KEY in another table.
Read more >
Inserting data into tables with referential constraints - IBM
Each non-null value you insert into a foreign key column must be equal to some value in the corresponding parent key of the...
Read more >
How to Create a Table with a Foreign Key in SQL
Another way to define a foreign key during table creation is to use the FOREIGN KEY REFERENCES clause at the end of the...
Read more >
SQL Foreign key - SQLShack
A Foreign key is constraint that enforces referential integrity in SQL server database. It uses a column or combination of columns that is...
Read more >
Create Foreign Key Relationships - SQL Server | Microsoft Learn
In Object Explorer, right-click the table that will be on the foreign-key side of the relationship and select Design. The table opens in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found