<foreignkey>

The <foreignkey> element defines a foreign key reference to another entity.

Attributes of <foreignkey>

The <foreignkey> element contains the following attributes.

<foreignkey>  attribute                  

Description

Default

archivingOwner

By default, a foreign key implies a relationship that the link target owns the source of the foreign key. Use the archivingOwner attribute to change the direction of this ownership relationship.

This attribute can be set to one of the following:

  • none – There is no ownership relationship between the source and the target of the link.
  • source – The source of the foreign key owns the link.
  • target – The target of the foreign key owns the link.

target

columnName

Optional. If specified, PolicyCenter uses this value as the column name of the corresponding database column. If you do not specify a columnName value, then PolicyCenter uses the value of the name attribute for the database column name.

The columnName attribute must be no more than 30 characters in length. It allows only unaccented Roman letters, numbers, and the underscore character. The first character of the columnName attribute must be a letter. Although the underscore character is allowable here, Guidewire discourages its use.

Note: As a common and recommended practice, use the suffix ID for the column name. For example, for a foreign key with the name Policy, set the columnName to PolicyID.

Guidewire does not require that you use an ID suffix on names of foreign key columns. However, Guidewire strongly recommends that you adopt this practice to help you analyze the database and identify foreign keys.

IMPORTANT All column names on a table must be unique in that table. Otherwise, Guidewire Studio™ displays an error if you verify the resource, and the application server fails to start.

None

createConstraint

If true, the database creates a foreign key constraint for this foreign key.

true

createbackingindex

If true, the database automatically creates a backing index on the foreign key. If set to false, the database does not create a backing index.

true

createhistogram

Whether to create a histogram on the column during an update to the database statistics.

Note: It is possible to override this attribute on an existing column in an extension (*.etx) file using the <column-override> element. You can use the override to turn off an existing histogram or to create one that did not previously exist.

This change does not take effect during an upgrade. The change occurs only if you regenerate statistics for the affected table by using the Guidewire maintenance_tools command.

See also

false

deprecated

If true, then PolicyCenter marks the item as deprecated in the Data Dictionary and places a Deprecated annotation on it in the Guidewire Studio API Reference.

If you deprecate an item, use the description to explain why.

For more information, see Data entity subelements.

false

desc

A description of the purpose and use of the field.

None

existingreferencesallowed

If the following attributes are set to false, which is not the default:

  • loadable
  • importableagainstexistingobject

then, the value in the staging table can only be a reference to an existing object.

true

exportable

Unused.

exportasid

Unused.

fkentity

Required. The entity to which this foreign key refers.

None

getterScriptability

See Data objects and scriptability for information.

all

ignoreForEvents

This attribute has complex, non-intuitive interactions with data entity relationships. See Interactions of ignoreForEvents attribute with data entity relationships for information on how to use and configure it.

false

importableagainstexistingobject

If true and the entity is importable (loadable), then the value in the staging table can be a reference to an existing object. (This is the publicID of a row in the source table for the referenced object.)

true

includeIdInIndex

If true, then include the ID as the last column in the backing index for the foreign key.

This is useful if the access pattern in one or more important queries is to join to this table through the foreign key. You can then use the ID to probe into a referencing table. The only columns that you need to access from the table are this foreign key, and the retired and ID columns.

In that case, adding the ID column to the index creates a covering index and eliminates the need to access the table.

false

loadable

If true, you can load the field through staging tables. A staging table can contain a column for the public ID of the referenced entity.

true

loadedByCallback

Internal. If true, then the loading code does not use a default value or report a warning if the column is nullable without a default.

false

name

Required. Specifies the name of the property on the entity.

None

nonEffDated

Internal. This applies only to a foreign key that points to an effdated entity. If a foreign key points to an effdated entity and this attribute is true, then PolicyCenter creates a real foreign key between the source and target entities.

false

nullok

Whether the field can contain null values.

true

overwrittenInStagingTable

Internal. If true (and the table is loadable), it indicates that the loader process auto-populates the staging table during import.

IMPORTANT If set to true, do not attempt to populate the table yourself because the loader import process overwrites this table.

false

required

Whether the foreign key is required to be non-null upon initial construction of instances of the entity. See Special behaviors for entity types during instantiation.

false

setterScriptability

See Data objects and scriptability for information.

all

soapnullok

Unused.

triggersValidation

Whether changes to the entity referred to by this foreign key trigger validation.

false

Subelements of <foreignkey>

The <foreignkey> element contains the following subelements.

<foreignkey>  subelement             

Attributes

Description

fulldescription

None

See <fulldescription>.

tag

None

See <tag>.