- To create a foreign key, right-click on the entity that will contain this field and select Actions > Create Foreign Key.
A wizard will appear where you fill in all necessary fields. Foreign Entity is the entity that you want your entity to link to. Foreign Field is in most cases the
Idfield (it must be a field that will uniquely identity the row). If you have a Lookup that you want to use for the foreign key you can select it from the drop-down list (it will e.g. show a customer's name based on his Id). Check or uncheck the box Allow Nulls depending on your preferences (if the foreign key field can remain empty or not). The FK Field Name is automatically created from the names of the foreign entity and field. It is recommended not to change it, because it shows the path to the referenced field. Use Caption for your own description of the field. After filling the fields, click on OK.
A tab prefilled by the wizard will open and you can edit other attributes. Save when finished.Note that the foreign key is a normal database field, only with the ForeignKey attributes filled in and DataType set to
Foreign key is a key used to link two relational database tables. It is a field or a group of fields in one table that uniquely identify a row of another table (primary key).