Enable Referential Integrity in a Microsoft SQL Server Database
SQL scripts for referential integrity can be generated with the IDE command line switch /genSql. The generated scripts map relationships defined in the application model to declarative constraints and database triggers in the database.
To enable referential integrity in the database:
-
Set the connector option
DBMS ri
in the assignment file. -
Add the following to the mss_entity.model_createReferentialIntegrity.sql scripts:
use DatabaseName go
where DatabaseName is the name of the database where the entities exist.
- Execute the SQL scripts to create referential integrity.
- Load the data into the tables.
-
Add the following to the mss_entity.model_validateReferentialIntegrity.sql scripts:
use DatabaseName go
where DatabaseName is the name of the database where the entities exist.
- Execute the SQL scripts to verify the referential integrity.
If you need to drop the referential integrity constraints for some reason:
-
Add the following to
mss_entity.model_deleteReferentialIntegrity.sql scripts:
use DatabaseName go
where DatabaseName is the name of the database where the entities exist.
- Execute the SQL scripts to drop referential integrity constraints.