Defining Attributes for a Class

When you have created classes from tables, the Define Attributes sheet of the External Schema Wizard then enables you to add attributes to a class, based on columns of the tables defined in the Define Classes sheet.

The creation of class attributes is a prerequisite for the definition of dictionaries.

An example of the Define Attributes sheet of the External Schema Wizard is shown in the following image.

The Classes list box lists all of the subclasses of the ExternalObject class defined for this external database schema. The Attributes table displays all of the potential and defined attributes for the class selected in the Classes list box.

The rows of the Attributes table are grouped into sections, with a separate section for each table included in the class. Each row of the table displays a check box at the left of a table column of one of the tables included in the class and a generated attribute name and default JADE primitive type for that attribute, based on the description of the table column from the relational database.

When you first access this sheet and no attributes are defined for a class, all the attributes in the Attributes table are checked. When you have added one or more attributes to a class, only those attributes are checked.

Rows in the Attributes table that correspond to an existing attribute for the selected class are displayed in black. Rows that do not correspond to an existing attribute are displayed in gray and enable you to change the attribute name by specifying the required name in an edit text box in the table. A changed attribute name is then displayed in black.

To define attributes for a class

  1. In the Classes list box, select the ExternalObject subclass whose attributes you want to define.

    The Attributes table is then automatically populated with all of the possible attributes that can be added to that class. If you have not yet defined any attributes for the selected class, all of the attributes in the Attributes table are checked.

    If you have added one or more attributes to that class, only those attributes are checked; that is, your previous selections are retained and displayed when you next access the Define Attributes sheet of the Wizard.

    Any attributes that correspond to primary key columns are always checked and added to the selected class, as these are required for references and update operations.

  2. To exclude a table column for transformation to an attribute, uncheck the check box at the left of that column in the Attributes table.

  3. When you have made the required changes to the attributes for the selected class, click the Save button. The attributes for that class are then saved.

    The selection in the Classes list box automatically moves to the next ExternalObject subclass that has no attributes defined for it in the Attributes table, enabling you to define attributes for each class.

  4. Repeat steps 1 through 3 for each ExternalObject subclass whose attributes you want to define.

  5. To change a generated attribute, select the attribute name and then click the Edit button. The Define Attributes dialog is then displayed. Options that are not valid for the changing of an external database schema attribute are disabled.

    You can change the attribute type, length, scale factor, precision, and access mode. For details, see "Adding an Attribute Property", in Chapter 4 of the JADE Development Environment User’s Guide.

    The JADE primitive type of the attribute can be changed only if a reasonable conversion exists. Symmetric conversions only are allowed. If a data type conversion produces a truncation or that type is not defined for your ODBC driver, an exception is raised at run time. For details, see "Mapping an SQL Data Type to a JADE Primitive Type", in Chapter 2.

  6. To delete a defined attribute, uncheck its check box and then click the Save button. Alternatively, select the required attribute in the Attributes table and then click the Remove button. (The Remove button is disabled if you have not selected an attribute or you have selected an attribute based on a primary key.)

    If the attribute is used anywhere in your schema, you are prompted to confirm that it is to be deleted.

  7. Click the Next > button when you have defined the attributes for your classes. (Alternatively, click the Close button to close the wizard.)

When you click the Next > button, the External Schema Wizard then enables you to define collections.

If you have made any changes to your attribute definitions that you have not yet saved, a warning is issued before the next sheet is displayed.