Defining a Referential Integrity Constraint by Creating an Entity Constraint

The Entity Constraint Wizard lets you add constraints, which are used when you generate tables with the Create Database Objects Tool (forward generation).

You can also create constraints while you define associations. In the Association Properties panel of the Association Wizard and Editor, select Use Database Key Constraints to automatically create a constraint based on the association.

An entity constraint is a business logic tier object that represents a key constraint in the database. An entity constraint describes, in terms of entity objects and attributes, the database-level relationships between tables and columns. You select the entity object's attributes and define the constraint in terms of database integrity constraints such as primary, foreign, check, or unique. When you create a database object based on an entity object, the definition of the entity constraint is used to detect associations between tables, create the specified key constraints in the database, and ensure that data in the database is valid and conforms to the key constraints.

To create an entity constraint with the Entity Constraint Wizard:

  1. In the Workspace view of the Navigator, right-click an entity object and choose Create Entity Constraint.

  2. If the Welcome page appears, click Next.

  3. In the Name page, enter the Java name for your key constraint in the Name field. For example, EmployeeSalaryKey.

  4. In the Constraint Name field enter the name of the constraint that the database will use. JDeveloper will provide a default name based on your choice of a constraint name. For example, EMPLOYEE_SALARY. Click Next.

  5. In the Attributes page, select the attributes that will participate in the key constraint. Use the right arrow button to move the desired items from the Available to the Selected list. Click Next.

  6. In the Properties page, enter specific details about the key constraint.

Key Constraint - Select the type of key constraint you want to create:

Validation Options - Select from these key validation options:

  1. When you are finished, click Finish to complete the wizard.