Key Fields

Set Protect_Key_State to true

Set Key_Field_State Field Customer.Id to true

Key fields are fields that have been designated to uniquely identify records in a table (e.g., customer_number in a customer table). The property used to designate key fields is Key_Field_State.

After you have designated key fields, you may set options for them all with Foreign_Field_Option.



Set Key_Field_State Field Customer.Id to true

Key_Field_State marks a field as the primary key field for the table.

One use of setting this option can be to prevent changes to the data stored in the field. This is known as key-field protection. Key-field protection allows data to be entered into the key field only when the record is first created. Once the record is created, the key-field data cannot be changed.

You would normally set this option on primary key fields such as the Order Number field in an Order Header table or the Customer ID field in the Customer table. This offers orphan prevention by preventing the ID fields used in parent-child relationships from being changed.

If your primary Key consists of multiple field segments, all fields in the key should be marked as Key Fields.

Key fields are only protected in a table if the Protect_Key_State property is also set in the Data Dictionary.



Set Protect_Key_State to true

Protect_Key_State determines if the fields that make up a primary key should be “protected” after they have been saved the first time in a new record.

When set to true, a field identified as being part of a key cannot be edited after it has been saved. This ensures that child records that relate to a parent through a primary key will not become accidentally orphaned.

The fields that make up a primary key are identified by using the Key_Field_State field property.

See Also

Defining Data Dictionary Table Attributes