Overview

A unique index in a IBM Cúram Social Program Management model is modeled by adding a relationship of stereotype uniqueindex between an entity class and a struct class. The rules for modeling a unique index are the same as those for modeling a non-unique index.

Specifying a unique index for an entity causes the necessary information to be included in the generated file <Application-name>_unique_constraints.xml which must then be referenced from the data manager configuration file (datamanager_config.xml).

Note that the file <Application-name>_unique_constraints.xml contains two sets of information:

  1. Unique indexes. These correspond to explicit ' uniqueindex ' relationships in the model and result in DDL of the form:
    CREATE UNIQUE INDEX <index-name>
            ON....

    where ' <index-name> ' is the name of the relationship in the model.

  2. Unique constraints. These are implicit unique constraints which are produced automatically by the generator and which are applied to all fields which are referenced by a foreign key. They correspond to foreignkey relationships in the model and result in DDL of the form:
    ALTER TABLE <table-name> ADD
            UNIQUE...

    or, if there is a uniqueindex for the fields referenced by the foreign key:

    ALTER TABLE
            <table-name> ADD CONSTRAINT <constraint-name>
            UNIQUE...

    where ' <constraint-name> ' is the name of the corresponding uniqueindex relationship in the model.

When the data manager is run, the explicit unique indexes are created before the implicit unique constraints. This allows the database to use the developer-specified unique indexes to enforce uniqueness rather than having to create and use its own system-named indexes. For example the developer may wish to model their specifically named unique index to correspond to a particular foreign key in the model. In this case the generator will automatically give the unique constraint the same name as the corresponding unique index.