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:

  1. Set the connector option DBMS ri in the assignment file.
  2. 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.

  3. Execute the SQL scripts to create referential integrity.
  4. Load the data into the tables.
  5. 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.

  6. Execute the SQL scripts to verify the referential integrity.

If you need to drop the referential integrity constraints for some reason:

  1. 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.

  2. Execute the SQL scripts to drop referential integrity constraints.

Related Topics