Set Alternate Key

An Alternate Key can only be specified for Persistent fields added to Custom Logical Units. By adding an Alternate Key to a Custom Logical Unit the system will prevent more than one record with the same combination of values to exist.

Each Logical Unit in IFS Applications, for example Order, Sales Part, or Customer, has a primary key. It is the field, or combination of several fields, that uniquely identifies each record. For the standard Logical Units included in IFS Applications this would be for example the Order Number, the Sales Part Number together with the Site, or the Customer ID. Only one record can exist with a specific Primary Key, so there must never be two Orders with Order Number '1234', or two Sales Parts with Sales Part Number 'PART' in Site 'A'. This is strictly enforced by IFS Applications so that the rule will never be broken. Apart from ensuring that each record is unique and being the identifier used by the system to distinguish each record, the Primary Key has the additional benefit of improving search performance in queries involving the Primary Key.

In contrast to the standard Logical Units in IFS Applications, all administrator created Custom Logical Units have a hidden primary key called Rowkey. The value of this field is generated automatically by the system and is never shown to the end user. Behind the scenes, it is used by the system to distinguish each record. It can also be used by an administrator to set up more advanced Custom Attributes and create new relationships between Logical Units. The same principle still applies though: each record has a unique Rowkey value, and this rule is strictly enforced by the system.

Adding an Alternate Key to a Custom Logical Unit is a way of mimicking the behavior of a Primary Key, to require one or more of the attributes the end user is working with to be unique. When an Alternate Key has been defined, the system will ensure that at most one record has a specific combination of attribute values. Just like a Primary Key, the search performance of queries on the attributes in the Alternate Key is improved.

Adding an attribute to the Alternate Key

To make an attribute part of the Alternate Key you select the Alternate Key check box on the Attribute row and save the changes. One or more attributes can be selected as the Alternate Key.

The next time the Custom Logical Unit is published or synchronized, the selected attribute or attributes will be set as the Alternate Key.

The selected Alternate Key is not valid with the data already stored in the Logical Unit

An error message will appear if the records that already exist in the Custom Logical Unit violates the principle of the Alternate Key: that each record must have a unique combination of values for the attribute or attributes in the Alternate Key. The Custom Logical Unit will not be possible to publish or synchronize until you have removed or changed the records that violate the desired Alternate Key.

Removing an attribute from the Alternate Key

To remove an attribute from the Alternate Key you clear the Alternate Key check box and save the changes. The next time the Custom Logical Unit is published or synchronized, the Alternate Key will consist of the selected attributes.

Removing one or more attribute from the Alternate Key could lead to the same problem with an invalid Alternate Key as adding attributes. Remove or change the records violating the desired Alternate Key to be able to publish or synchronize the Custom Logical Unit.

Example

A Custom Logical Unit called Fruit has been created with the attributes Name, Country, and Color. By making Name and Country part of the Alternate Key (indicated by the underline below) we can make sure that each entered combination of Name and Country is unique.

Name Country Color

Adding a valid record

The following data has previously been entered and saved into the Custom Logical Unit Fruit:
Trying to add the following record would be allowed, because no other record with the same combination of Name and Country exists:

Name Country Color
Apple USA Red

 

Adding an invalid record

Trying to add the following record would however be prohibited by the system, since another record with the Name Apple and Country Sweden already exists. It does not matter that the Color is different, since Color is not part of the Alternate Key.

Name Country Color
Apple Sweden Green

Changing the Alternate Key

The following data is present in the Custom Logical Unit Fruit:

The Alternate Key is still defined as Name and Country

Name Country Color

 

Trying to remove Country as a part of the Alternate Key, leaving only Name, will lead to an error because the Alternate Key is no longer valid. This is because Name must be unique among all records, and since two records with the name Apple exists, the Alternate Key is not valid. To be able to use the desired Alternate Key, either remove or change one of the records with the Name Apple.