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:
Attribute | Domain |
---|---|
key accountNo | ACCOUNT_NO |
details clientID | CLIENT_ID |
details branchLocation | BRANCH_LOCATION |
details currentBalance | MONEY |
details lastTransaction | DATE_TYPE |
details lastStatement | DATE_TYPE |
Attribute | Domain |
---|---|
key txAccountNo | ACCOUNT_NO |
details txID | TX_ID |
details transactionDate | TX_DATE |
details transactionType | TX_TYPE |
details transactionAmount | TX_AMOUNT |
This foreign key results the following DDL being generated (Oracle SQL shown):
ALTER TABLE BankTransaction ADD( FOREIGN KEY (txAccountNo) REFERENCES BankAccount(accountNo));