Primary Key - A variable in a STAF table which uniquely identifies a row or set of related rows. This might or might not be set equal to the row number.
Foreign Key - A variable in a STAF table that refers to a row or set of related rows in the same or in another table. The reference is not a pointer to a memory address, but rather, the relationship is indicated by the numerical value assigned to the foreign key. For example, refer to the tcl_tphit and tpt_track tables which contain TPC space points and tracks. In order to relate all the TPC space points which were assigned to a certain TPC track we set the foreign keys in tcl_tphit according to:
for i = row number of all assigned space points to the track on row j in table tpt_track.
The Foreign key values are equatted to the appropriate Primary key value,
NEVER TO THE ROW NUMBER.
SOFI has developed several tools to facilitate Primary/Foreign key usage in STAF modules. These tools and other important guidelines are presented in the above document.