0
Accepted

How do I add an FK to an existing column

andrew 1 year ago updated by Support 1 year ago 2

I've imported an existing schema that didn't have any FK's set, but all of the columns are there ready for the FK.

So, how can i add a new FK for the PK of the parent table to the existing column in the child table.

At the moment I have to delete the column and add the FK, otherwise it adds the column in again with a "_1" suffix.

Thanks

Andrew

Answer

Answer
Under review

To connect two table, tool creates new FK column in child table, this is done deliberately to avoid any mistakes by the user. Otherwise there are lot of chances of mistake, like not all the properties/attributes of the column be same. For example if Parent column PK is of datatype nvarchar(45), and child table column (which user wants to make as FK) is nvarchar(46).


Probably, in future we will add the feature where when user tries to add relationship, and the tool finds same column in child table with same properties/attributes, then use existing column.

For now,  just delete the column and create relationships, which makes sure that new FK column has correct attributes.

Thanks

Team - SqlDBM

Answer
Under review

To connect two table, tool creates new FK column in child table, this is done deliberately to avoid any mistakes by the user. Otherwise there are lot of chances of mistake, like not all the properties/attributes of the column be same. For example if Parent column PK is of datatype nvarchar(45), and child table column (which user wants to make as FK) is nvarchar(46).


Probably, in future we will add the feature where when user tries to add relationship, and the tool finds same column in child table with same properties/attributes, then use existing column.

For now,  just delete the column and create relationships, which makes sure that new FK column has correct attributes.

Thanks

Team - SqlDBM