Are you having trouble finding data to debug an issue? Are your queries to a transaction table slow? Did you get a requirement to display activity history for a user? Your Appian application’s data model design and data deletion strategy can have a major role in how these questions or concerns can be addressed. When designing the data model for your Appian application, there are different approaches to consider for data deletion use cases. The approach you choose will probably depend on the nature of the data, the number of transactions, and the business rules associated with the use case. The most common approaches include:
This article describes the pros and cons of each deletion approach and provides recommendations on when to use these approaches. For the purposes of this article, the relational database data model from the Quote to Order case study is referenced for examples.
Figure 1: Quote to Order ERD
The term ”hard delete” is generally accepted to describe the irrevocable removal of data. When a value or row is hard-deleted from a table, it means a DELETE operation has been executed on a row in the table. This is typically the easiest and fastest option for developers, independent of business rules.
NOTE: It is recommended to use the Delete from Data Store Entities smart service for hard deleting data from Appian applications. Make sure the deletes are based on an indexed field (ideally the primary key field). You may run the EXPLAIN statement to see the execution plan prior to the delete. If you are deleting in bulk and there’s HA setup at the database layer, it’s preferred to purge in batches (limit to 1000 rows per batch) and during off hours to minimize the impact (database locking) on the application . Be aware of the foreign key constraints and cascade attribute settings in the database schema and make sure your data is backed up prior to the delete in case you need to restore it.
By contrast to a hard delete, data is typically retained according to a soft delete strategy. Instead of deleting the data, the table row to be soft deleted is marked with a value in a dedicated column.. This option seems less risky in terms of losing data due to hard deletes but could be risky in terms of unintended data showing up in reports or other parts of the application or compromising the performance of the table.
A less invasive approach to deleting data in a table involves creating an audit log of delete operations on the table. It is very common for application designers to have an auditing strategy to record changes done by users in the application. So the audit log approach for recording deletes that happen on a table, as a result of a user’s action or as a business rule, fits right into that strategy. Detailed guidance on implementing audit tables for Appian applications can be found in the Auditing Guidance docs and the Field Level Auditing play.
The Quote to Order data model includes the table QTOA_HISTORICAL_ORDER as part of a data archival strategy. This type of strategy helps with overall application performance. “Mirror” tables that match the structure of the original transaction tables are core to this approach. With these tables in place, a design can be employed in which the application switches between them to access appropriate data depending on its age. For example, in the Quote to Order data model the QTOT_ORDER table has a corresponding QTOA_HISTORICAL_ORDER table. Data from the QTOT_ORDER table is archived to the QTOA_HISTORICAL_ORDER table if it is older than six months and eventually to long term storage after it ages out further. This keeps the size of the QTOT_ORDER table reasonably low leading to better performance.
A data deletion strategy should be based on the nature of the data and the business case. In summary, use a hybrid implementation approach wherein: