Using Unique, Generic, and Replica Field Specifications

  Previous section   Next section

Earlier in this chapter, you learned that you could define a specification as Unique, Generic, or Replica. You can ensure that you define the appropriate type of specification for a given field by following these simple guidelines:

  • Use a Unique specification for any field that will appear only once within the entire database or for a field that serves as a primary key.

  • Use a Generic specification for a field that serves as a template for other fields within the database. Remember to use a nonspecific field name and element settings that are as broad and general as possible.

  • Use a Replica specification for a field that you base on a given generic field or for a field that serves as a foreign key within a table relationship.

Figure 9.8 shows the complete Unique field specification for a VENDOR ID NUMBER field.

Figure 9.8. Unique field specification for the VENDOR ID NUMBER field.

graphics/09fig08.jpg

Here are a few things to note about this specification:

  1. This field also appears in the PRODUCTS table, as indicated by the Shared By general element. This is both reasonable and necessary because each product must be associated with a specific vendor. (You'll learn more about this type of issue in the next chapter.)

  2. Examine the settings for the Uniqueness, Null Support, Required Value, and Edit Rule logical elements. They are set in this manner because the Key Type element is set to "Primary." You should, in fact, use these element settings for any field that serves as a primary key.

  3. The Comparisons Allowed logical element is set to "Same FieldEquals" so that a user can compare VENDOR ID NUMBER values in the VENDORS table to VENDOR ID NUMBER values in the PRODUCTS table.

  4. The Comparisons Allowed logical element is also set to "Value ExpressionEquals" so that a user can compare VENDOR ID NUMBER values to some arbitrary numeric value.

Figure 9.9 shows the complete Generic field specification for a generic STATE field.

Figure 9.9. Generic field specification for a generic STATE field.

graphics/09fig09.jpg

Take note of these particular items:

  1. The description is very general, as it should be for this type of specification.

  2. The setting of the Display Format physical element is in the form of an instruction. This demonstrates that you have a great deal of flexibility in the way you set this element.

  3. The Range of Values logical element is appropriately broad.

  4. The Comparisons Allowed logical element is set to "Value ExpressionEquals" so that a user can compare STATE values to some arbitrary two-character alphanumeric value.

  5. The Operations Allowed logical element is set to "Other FieldsConcatenation" so that a user can concatenate a given STATE value to the value of some other alphanumeric field.

  6. The Operations Allowed logical element is also set to "Value ExpressionConcatenation" so that a user can concatenate a given STATE value to some arbitrary alphanumeric value.

This field (and its specification) now serves as a template for all other state fields you create in the database. For example, you can create a VENDSTATE field based on the generic STATE field. You'll define a Replica specification for the VENDSTATE field that is based on the STATE field's Generic specification. Although the VENDSTATE field's Replica specification draws its initial element settings from the STATE field's Generic specification, you can modify any of the Replica specification's element settings so that you can completely customize them for the VENDSTATE field. Figure 9.10 shows the customized Replica field specifications for the VENDSTATE field.

Figure 9.10. Customized Replica field specification for the VENDSTATE field.

graphics/09fig10.jpg

Here are a few things to note about this specification:

  1. The field name (VENDSTATE) accurately denotes what the field represents.

  2. The label ("State") is what the user will see on visual displays and printed documents.

  3. The Source Specification general element properly references the generic STATE field's specification.

  4. The Description element is now specific to this field. Recall that the description is more general in the source specification.

  5. A default value has been set for this field; there is no such value in the source specification.

  6. The Range of Values element is now specific to this field; it was much broader in the source specification.

In the next chapter, you'll learn how to define a Replica field specification for a field that serves as a foreign key.


Top

Part II: The Design Process