0
Completed

how to set foreign key

Anik Chowdhury 10 years ago updated by victor maricato 4 years ago 6
+1
Under review
Foreign key definition is a part of reference. Click on the reference to add/remove FK/PK column pairs. 

Here is a instruction how to create a reference: http://support.vertabelo.com/topic/438421-how-to-c...


When I try and create references, the software always generates a new column as a foreign key. Is it possible to set existing columns as foreign key instead?
When creating my tables primary keys are already set into child tables which would be the foreign keys. When I draw the reference line across it still just adds another column that I don't require.
For junction tables I am setting the primary as a compound key but those columns are also the foreign keys from the 2 parent tables. On my course we have to add foreign key constraints as a separate sql command. This is my first database so some confusion but I am trying to use a data modeller for clarity instead of working purley from the SQL command prompt in oracle.
thanks
Rob
-2
Hi,

Some users complain about auto-creation of foreign columns. This can be turned off in the next release. Here is a topic http://support.vertabelo.com/topic/588498-do-not-auto-create-foreign-key-reference/

You can set existing columns as a foreign keys.
1. Click on the reference.
2. Select PK column and FK column
3 Click "Add".

Here is a screenshot:




+2

But how do we add a foreign key if the reference has already been added? I did not want to column name they auto-generated, so I deleted it. Which leaves no way to create foreign key. They should have just put a checkbox where PK is in the columns section. Super easy then.