Deleting records can be performed in many ways: directly from the xDM application, using SQL, or using the Rest API. In any case, it needs some model configurations. This article explains what should be configured to enable deletion, and how to perform the record deletion in all possible ways.
Please note that record deletion is possible for golden records. Deleting a golden record deletes all related masters during the process. |
Enable deletion
To support any record deletion, you must enable deletion on the concerned entity and check all reference relationships to this entity:
- In the model design, select the Delete Enabled option in the entity properties:
- Check each relation defined in the Is Referenced By menu for your entity:
- In the Delete Propagationproperty, you must choose the appropriate type:
- Cascade will propagate the delete to the referencing entity records (which Enable Delete option should be selected)
- Nullify will update the referencing entity records and set the foreign key to null
- Restrict will forbid the deletion if some children are referencing the parent entity record
Refer to the Developer Guide for more information about the configuration of reference relationships.
Delete records
Now that you have enabled deletion, you can perform the delete. Whichever the way you want to delete the records (within the application, using SQL, or using the REST API), you will be asked to choose between Hard and Soft delete:
- Hard Delete: physically deletes records from the hub database. Data cannot be recovered.
- Soft Delete: logically deletes records by moving them to a deleted records storage.
Within the application
To let the users delete records from the app, you should add a Delete action in the entity action sets:
This will make the Delete action available according to your action configuration:
Using SQL
Deleting a record using SQL consists of loading a record in the SA table with the following parameters:
B_LOADID
B_DELETETYPE
B_DELETEOPERATION
- The Golden ID
- Optionally,
B_DELETEAUTHOR
andB_DELETEDATE
For example, to hard delete the golden Customer 37696:
INSERT into SEMARCHY_MDM.SA_PERSON (B_LOADID, B_CLASSNAME, B_CREDATE, ID, B_DELETETYPE, B_DELETEOPERATION, B_DELETEAUTHOR, B_DELETEDATE) VALUES (156, 'Person', sysdate, 37696, 'SOFT_DELETE', RAWTOHEX(SYS_GUID()), 'ETL_USER', sysdate)
You must execute this query after initializing the load and before submitting the load.
Refer to the Integration Guide for more information about publishing record deletion using SQL
Using the REST API
To delete records using the Rest API, you must call the loading Data URL and provide in the payload:
- The
DELETE_DATA
action deleteOptions
element containing thedeleteType
,deleteRecords
element containing the entity and Golden IDs to delete.
To use the same example as in SQL, to hard delete the golden Customer 37696 the payload should look like:
{
""action"":""DELETE_DATA"",
""deleteOptions"": {
""deleteType"": ""HARD_DELETE""
},
""deleteRecords"": {
""Person"": [ { ""ID"": ""37696"" } ],
}
}
You should send this request after initializing the load and before submitting the load.
Refer to the Integration Guide for more information about publishing deletion using the REST API.