Try OpenEdge Now
skip to main content
DataServer for Microsoft SQL Server
The DataServer Tutorial : Managing server attributes : Defining a foreign key constraint definition
 

Defining a foreign key constraint definition

The following procedure describes how to define a foreign key constraint definition.
To define a foreign key constraint definition:
1. Start Data Administration and connect to the OpenEdge database you are migrating.
2. Select DataServer > MS SQL Server Utilities > Server Attributes > View/Maintain Foreign Constraints.
The View/Maintain Foreign Constraint Definitions dialog box appears.
3. Select the table for which you are defining a foreign key constraint definition and click Create Constraints.
The Create Foreign Constraint Definitions for tablename dialog box appears, as shown in Figure 18.
4. Select FOREIGN KEY from Constraint Type.
The Create Foreign Constraint Definitions for tablename dialog box, appears as shown in the following figure.
Figure 20. Create Foreign Constraint Definitions for tablename dialog box for foreign key constraint definitions
5. Accept the generated default constraint definition name, or enter a new one.
6. The Parent Table/Parent Index lists the indexes from all of the other tables defined in the OpenEdge database, available for selection. For the DataServer for MS SQL Server, the list shows primary and unique indexes. Below the parent index information is the Child Index list. The Child Index list shows the available indexes for the selected table. For both parent and child indexes, the Index Key Composite Fields shows the columns that comprise the indexes. Select an index from the parent and child lists with matching composite fields.
7. By default, the foreign key constraint definition has the Active check box selected. Leave this box selected if you want the constraint definition you are defining to be available for migration.
8. Select an appropriate action item from the Constraint Action.
Constraint actions can be NONE, CASCADE, SET NULL, or SET DEFAULT. A typical constraint definition action ensures that the data integrity, in case you need to delete data in the rows of a referenced table.
The NONE constraint action ensures data is not deleted from a row which exists in a foreign key table that references the value in the referenced table.
The CASCADE constraint action ensures that whenever you delete rows in the master (referenced) table, the respective rows of the child (referencing) table with a matching foreign key column is deleted.
The SET NULL constraint action ensures that the foreign key values in the referencing row are set to NULL when the referenced row is deleted.
The SET DEFAULT constraint action ensures that foreign key values in the referencing row are set to the column default when the referenced row is deleted.
9. Add a description of the constraint definition in the Description fill-in, if desired.
10. Click OK to save the constraint definition and exit the dialog box. Click Create to save the constraint definition and remain in the dialog box and continue defining constraint definitions for the selected table.