Skip to main content
Answer

Relationships incorrect in export from ERD to SQL

  • April 6, 2022
  • 6 replies
  • 282 views

paulkrug

I'm exporting an ERD to SQL Server. The diagram consists of one entity with relationships to three other tables. Looking at the generated SQL the foreign keys are set up incorrectly. A FK that references table A for example uses the column that is the foreign key to table B.

Am I doing something wrong? Any way to fix this other than manually edit the generated SQL each time I export?

Best answer by paulkrug

I found the problem. The relationships need to be connected to the corresponding table at the connection points for the corresponding columns. 

Issue resolved.

Comments

paulkrug
  • Author
  • Answer
  • April 6, 2022

I found the problem. The relationships need to be connected to the corresponding table at the connection points for the corresponding columns. 

Issue resolved.


Abigail M
Forum|alt.badge.img+7
  • Lucid support team
  • April 6, 2022

Hi Paul thanks for following up with that resolution! If anyone else is experiencing issues with ERD > SQL export feel free to post your question in this thread.


Yasir A
  • August 18, 2023

The query provided by Lucidchart import (ERD > SQL export) is not retrieving the foreign keys at all.  As a result the tables are not connecting with each other when I drag them into the doc.  I'm using a PostgreSQL DB and there are foreign keys defined in the schema for my DB.  Would appreciate any help in tweaking the query to pull the FKs.  Thanks!


Whittney C
Forum|alt.badge.img+6
  • Lucidite
  • August 18, 2023

Hi Yasir thanks for commenting in our community! You've provided some great information about the problems you are experiencing with our ERD import. I am going to have a member of our support team reach out with some more specific questions via email so we can take a deeper look. 


Forum|alt.badge.img+3
  • November 26, 2024

I am having a similar issue with my ERD exporting to PostgreSQL. About one-half (8 of 15) FK relationships are not exporting, and ultimately are not created. 

How do we verify the connections are made between the two. For instance, I connect the PK of the sub-table to an FK in the primary table visually but, when exporting, that relationship disappears. 

When exporting a CSV from my manually created ERD, the relationships appear in the appropriate columns. So, this suggests to me the code export to PostgreSQL is the primary issue.

I have screenshots and the various code documents to send but, would appreciate answers being published here for the next person. 

Any help would be appreciated.


Kelsey Gaag
Forum|alt.badge.img+16
  • Lucidite
  • November 26, 2024

Hi ​@jerryhall

Thank you for your reply to this thread! It sounds like you may be experiencing a current bug in our system. Do you mind checking out this post to see if you are experiencing the same / related issue?