How to: Build Referential Integrity Between Tables
You can create a set of rules to preserve the relationships defined between database tables when adding, updating, or deleting records. The process of creating these rules is called building referential integrity.
To build referential integrity between tables
Open the database in the Database Designer.
In the Database Designer, create a new persistent relationship between two tables or choose an existing relationship by clicking the relationship line.
On the Database menu, click Edit Referential Integrity.
In the Referential Integrity Builder, select the rules you want to enforce for updating, deleting, or inserting records.
To save your changes, generate RI code, and exit the builder, click OK, and then Yes.
For more information, see Referential Integrity Builder.
When you use the RI Builder, Visual FoxPro generates code for enforcing referential integrity rules and saves it as triggers that reference stored procedures. A trigger is an expression that is bound to a table and is invoked when table records are modified by specified data manipulating commands. You can view this code by opening the stored procedure text editor for your database. For more information, see Trigger Usage and How to: Create and Manage Stored Procedures.
Warning
Run the RI Builder again when you make changes to a database such as modifying database tables or altering indexes used in a persistent relationship before you use the database. Rerunning the RI Builder updates stored procedure code and table triggers used to enforce referential integrity. If you do not rerun the RI Builder, you might receive unexpected results because the stored procedures and triggers were not updated.
See Also
Tasks
How to: Create Persistent Relationships Between Tables
How to: Create and Manage Stored Procedures