next up previous contents
Next: STAF - Architecture Up: STAR Software Infrastructure Tools Previous: STAF - Sorting Out

STAF - Primary and Foreign Keys

  New users and, for that matter, experienced users are strongly urged to review a document entitled, ``Proposed Rules and Tools for PAM Initialization and Foreign Key Usage,'' which lists a concise set of rules and steps to follow to insure proper initialization of a module and to correctly use the Primary and Foreign key features of STAF tables which allows information in different tables to be related. These quantities are defined as:



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.


Example: tableX(i).id

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:


tcl_tphit(i).track = tpt_track(j).id

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.


next up previous contents
Next: STAF - Architecture Up: STAR Software Infrastructure Tools Previous: STAF - Sorting Out
Lanny Ray
2/20/1998