Microsoft KB Archive/136855

= When to Use Buffering, Referential Integrity, and Triggers =

Article ID: 136855

Article Last Modified on 11/17/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 6.0 Professional Edition
 * Microsoft Visual FoxPro 3.0b for Macintosh

-



This article was previously published under Q136855



SUMMARY
This article explains the differences between buffering, referential integrity (RI), and triggers, and it describes when each should be used.



Buffering
To directly update tables or records in a multiuser environment, use row and table buffering. This eliminates the need to place the data from a record into memory variables (memvars), edit the memvars, check the record for changes, and then write the changes to the record. See the Buffering topic in the Visual FoxPro Help file for more detailed information.

Referential Integrity (RI)
This refers to the rules that govern data integrity between related tables (primary key/foreign key). In addition to using engine-level enforcement of primary keys, you can create stored procedures that take certain actions when a row is updated, deleted, or inserted.

The RI Builder will create one of the following stored procedures for each action:


 * Update: Ignore, Cascade, or Restrict
 * Delete: Ignore, Cascade, or Restrict
 * Insert: Ignore and Restrict

The names of these stored procedures are placed under the proper trigger in the Table Properties section of the Table Designer.

Triggers
Record-level event code runs after an insert, update, or delete. triggers run after rules, and they do not run when buffering is in effect until TABLEUPDATE is issued. In the case of row buffering, the record pointer is moved.

Triggers can be created by using the CREATE TRIGGER command or by adding a stored procedure to the Database Container and referencing the stored procedure in the appropriate trigger in the Table Properties dialog box of the Table Designer.

Buffering and RI can be used independently of each other, and the use of RI does not necessarily mandate that buffering be used. In a multiuser environment, you would typically use buffering whether or not any RI was in place.

Although triggers are typically used to implement (by using the RI Builder) Cascade or Restrict capabilities on Update and Delete, or Restrict capabilities on Insert, these Triggers can also be used to call stored procedures that undertake actions wholly unrelated to RI. For example, an Update Trigger might call a stored procedure that sends an email message to another department to notify them of a change.

Additional query words: VFoxMac VFoxWin multi-user

Keywords: KB136855

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.