When you are creating relationships between the entities in your eSpace, you can define which kind of referential integrity you want to use when deleting records. The referential integrity specifies what happens to an Entity B record that references an Entity A record, when the Entity A record is deleted.

To specify the referential integrity rule you want to use, you have set the Delete Rule property of the reference attribute, which corresponds in database terminology to a foreign key. The possible values of this property are explained below.

Protect

Prevents deleting records in Entity A while there are associated records in Entity B, assuming that there is a relationship between Entity A and Entity B and that the reference attribute is in Entity B. If you try to delete a record in Entity A that still has associated records in Entity B, the Platform Server returns a database exception and this operation is not executed.

To implement Protect behavior you simply have to set the Delete Rule property of the reference attribute with the Protect value. As a consequence, a database constraint on the reference attribute will be created.

Protect is the default value of the Delete Rule property in relationships between entities of your eSpace and/or entities exposed by other eSpaces.

Example scenario:

To implement these business rules, edit CustomerId attribute and set the Delete Rule property to Protect.

Service Studio allows you to use the Protect delete rule in relationships between entities that are stored in Platform Database and, therefore, referential integrity can be guaranteed. When creating relationships between your entities and entities references, you must be aware that the Protect rule can only be used when the producer of the entity reference is an eSpace. Otherwise, the delete rule must be Ignore.

Delete

Deleting records in entity A implies that all the related records in entity B are also deleted, assuming that there is a relationship between entity A and entity B and that the reference attribute is in entity B. This mechanism is commonly known as Cascade Delete.

To implement Delete behavior you simply have to set the Delete Rule property of the reference attribute to the Delete value. As a consequence, a database constraint on the reference attribute will be created.

Example scenario:

To implement these business rules, edit OrderId attribute and set the Delete Rule property to Delete.

Service Studio allows you to use the Delete delete rule in relationships between entities that are stored in a Hub Database and, therefore, referential integrity can be guaranteed. When creating relationships between your entities and entities references, you must be aware that the Delete rule option can only be used when the producer of the entity reference is an eSpace. Otherwise, the delete rule must be Ignore.

Ignore

Deleting records in entity A means that only the records in entity A are deleted, even if there are related records in entity B, assuming that there is a relationship between entity A and entity B and that the reference attribute is in entity B.

Ignore is the default value of the Delete Rule property in relationships between an entity of your eSpace and an entity exposed by extensions.

Example scenario:

To implement these business rules, edit OrderId attribute and set the Delete Rule property to Ignore.

Since this type of delete rule does not require any database constraints, you can use it in relationships between your entities and any entity you added as a reference to your eSpace, no matter if its producer is an eSpace or an extension.

This delete rule does not guarantee referential integrity and, therefore, no constraints are created in the DBMS. Accordingly, when a reference attribute Delete Rule property is changed to Ignore, the corresponding automatic index is deleted unless any of its properties have changed.

See Also

Manage Entities | Create Relationships | Database Constraints | Database Indexes