I ll assume you re asking because you read the documentation and it didn t make sense to you.
A foreign key (FK) is a field in TableB that holds the same value as a field, usually the primary key (PK), in TableA. So in pseudocode:
Create TableA:
A_id is PK,
somefield,
anotherfield
Create TableB:
B_id is PK,
A_id is FK to TableA,
farmfield,
outstandingfield
Create constraint on TableB:
In TableB A_id references TableA(A_id),
Don t allow updates to TableA(A_id),
Delete records from TableB that have the same A_id as deleted records in TableA
Then when you do a query that involves both tables, you can join on your FK:
SELECT a.somefield, b.farmfield FROM TableA a JOIN TableB b ON (a.A_id=B.A_id);
And when you delete from TableA, you don t have to delete from TableB. It will happen automatically because the constraint said "Delete records from TableB that have the same A_id as deleted records in TableA".
And when you insert into TableB, you ll either have to give a valid A_id, or, depending on how you defined the column, leave A_id =NULL
.