Example

Consider two entity classes, BankAccount and BankTransaction, where BankAccount. accountNo is a foreignkey on BankTransaction. That is, the BankTransaction table (txAccountNo) must have a record on the BankAccount table with a matching accountNo value.

The tables below illustrate these two classes where the foreignkey would be between their key attributes:

This foreign key results the following DDL being generated (Oracle SQL shown):

ALTER TABLE BankTransaction ADD(
  FOREIGN KEY (txAccountNo)
  REFERENCES BankAccount(accountNo));